Skip to content

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
  1. Closing a tip
  2. When to use it
  3. For everyone
  4. Props

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

CloseButtonTypeDefault
onPressrequired () => void
label string
size "sm" | "md" | "lg" sm
  1. Closing a tip
  2. When to use it
  3. For everyone
  4. Props

    Search pages, sections and terms