Row
Cosas una al lado de otra, centradas en una línea. Cuando no caben, pasan a la línea siguiente en vez de desbordarse.
import { Row } from '@sypnia/ui/react'
El encabezado de una lista
justify="between" separa los dos grupos; cada grupo es un Row propio.
Código
import { Badge, Button, Row, SearchInput } from '@sypnia/ui/react';
export default function Header() {
return (
<Row justify="between" gap={3}>
<Row gap={2}><strong>Tables</strong><Badge>12</Badge></Row>
<Row gap={2}>
<SearchInput aria-label="Find a table" placeholder="Find a table" />
<Button variant="primary" icon="plus">New table</Button>
</Row>
</Row>
);
} De a dos en el celular
pairs: en el celular una barra de opciones se vuelve una cuadrícula de dos columnas, así nada se desplaza de lado. Achica la ventana para verlo.
Código
import { Button, Row } from '@sypnia/ui/react';
// On phones the four buttons sit two by two: nothing scrolls sideways.
export default function Pairs() {
return (
<Row pairs gap={2}>
<Button>Today</Button>
<Button>This week</Button>
<Button>This month</Button>
<Button>All time</Button>
</Row>
);
} Uno ocupa el espacio que queda
fill: el primer elemento crece hasta ocupar el espacio que dejan los demás. Cuando la fila no le da 18rem, los demás pasan a la línea siguiente.
Código
import { Button, Input, Row } from '@sypnia/ui/react';
// The field takes the room the button leaves. On a narrow screen the button goes to the next line.
export default function Fill() {
return (
<Row fill gap={2}>
<Input aria-label="Name of your business" defaultValue="laespiga" />
<Button variant="primary" icon="search">Search</Button>
</Row>
);
} Cuándo usarlo
Úsalo cuando
- Un título y su insignia, un grupo de botones, un campo y su botón.
- Una barra de opciones que debe ir de a dos en el celular (
pairs). - Una cosa que ocupa el espacio que dejan las demás: un campo junto a su botón, un mapa junto a un teléfono (
fill).
No lo uses cuando
- Los elementos son controles de una herramienta y se usan con el teclado: eso es un Toolbar.
- Muchos elementos iguales, como tarjetas: eso es un Grid.
Para todos
- Al pasar de línea, todo queda visible y en orden de lectura: nada se esconde detrás de un desplazamiento lateral.
Props
| Row | Tipo | Por defecto |
|---|---|---|
as | ElementType | div |
className | string | |
fillThe first item takes the room the others leave: a map beside a phone, a field beside its button. When the row is too narrow for it (under 18rem) the others go to the next line. | boolean | |
gap | Gap | |
id | string | |
justifyWhere the items go along the row. | "start" | "end" | "between" | start |
nowrapKeep everything on one line. | boolean | |
pairsOn phones, lay the items out two by two (bars of options). | boolean | |
style | CSSProperties | |
topAlign to the top instead of the middle (for items of different heights). | boolean |