CloseButton
Closes the thing it sits in: a tip, a panel, a card. Dialogs, drawers and toasts already have their own.
import { CloseButton } from '@sypnia/ui/react'
On this page
Closing a tip
Code
import { useState } from 'react';
import { Button, Callout, CloseButton } from '@sypnia/ui/react';
// It closes what it sits in, and its name says what.
export default function Panel() {
const [open, setOpen] = useState(true);
return open ? (
<div className="sy-row sy-row--between sy-row--top">
<Callout title="Your first table">Tables hold your data in rows and columns. Start with one and add columns as you need them.</Callout>
<CloseButton onPress={() => setOpen(false)} label="Close the tip" />
</div>
) : <Button size="sm" onClick={() => setOpen(true)}>Show the tip again</Button>;
} When to use it
Use it when
- A panel or a tip that the person may put away.
- Name what it closes: «Close the tip».
Do not use it when
- Dialogs and drawers: they bring their own.
- Removing something for good: use a quiet danger button and ask first.
For everyone
- It shows an icon and has a name for screen readers.
- After closing, put the focus somewhere sensible, such as the button that brings it back.
Props
| CloseButton | Type | Default |
|---|---|---|
onPressrequired | () => void | |
label | string | |
size | "sm" | "md" | "lg" | sm |