NewCard
The dashed card at the end of a grid that creates one more of the things beside it.
import { NewCard } from '@sypnia/ui/react'
At the end of a grid
Press it.
Code
import { Card, NewCard, toast, Toaster } from '@sypnia/ui/react';
// It sits at the end of the grid it adds to, with the same size as its neighbours.
export default function InAGrid() {
return (
<>
<div className="sy-grid">
<Card title="Storefront" href="#storefront">5 tables · 5,552 rows</Card>
<Card title="Back office" href="#back-office">12 tables · 48,210 rows</Card>
<NewCard onClick={() => toast('This would open «New project»', { tone: 'info' })}>New project</NewCard>
</div>
<Toaster />
</>
);
} As links
Two ways to begin, each leading to its own page.
Code
import { NewCard } from '@sypnia/ui/react';
// With href it is a link to the page that creates the thing.
export default function Alone() {
return (
<div className="sy-grid">
<NewCard href="#new-table">New table</NewCard>
<NewCard href="#import">Import a CSV file</NewCard>
</div>
);
} When to use it
Use it when
- A grid of cards the person can add to: projects, tables, boards.
- It goes last, so it is always in the same place.
Do not use it when
- The page already has a primary «New…» button in its header and the grid is long: one way in is enough.
- The things are in a table: the button goes in the page header or the table toolbar.
- The place is empty: an EmptyState explains more than a lone dashed card.
For everyone
- It is a real button (or link, with
href) named by its text: «New project». - The plus is decoration; the words say what will be created.
- It has the same size as the cards beside it, so it is as easy to hit as they are.
Props
| NewCard | Type | Default |
|---|---|---|
href | string | |
onClick | (() => void) |