• Docs
  • Blog
    • 0.24.0

    • Switch to dark mode
    Get Started
    Components
    Styling
    Theming

    Concepts

    OverviewCompositionTesting

    Layout

    Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridLink OverlayScrollableStackWrap

    Components

    AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMenuNotificationsNumber InputPin InputProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

    Utilities

    Feature FlagsForLocal StoragePortalShowsplitPropsTheme

    Tag

    The Tag component is used to display labels or tags with various styles and functionalities.

    • npm
    • source
    • recipe
    import { Tag } from '@cerberus/react'

    Basic Usage

    You can mix and match all of the examples to create the tag style of your choosing.

    FilledStart iconEnd icon

    Usage Variants

    Tags come in two usage variants: outlined and filled.

    FilledOutlined

    Shape Variants

    Tags come in two shape variants: square and pill.

    PillSquare

    Colors

    You can set the color of the tag by using the palette prop. By nature of CSS rules, only one of palette or gradient can be used at a time.

    page:
    Label
    Label
    Label
    Label
    secondaryAction:
    Label
    Label
    Label
    Label
    info:
    Label
    Label
    Label
    Label
    success:
    Label
    Label
    Label
    Label
    warning:
    Label
    Label
    Label
    Label
    danger:
    Label
    Label
    Label
    Label

    Gradients

    You can set the gradient of the tag by using the gradient prop. By nature of CSS rules, only one of palette or gradient can be used at a time.

    charon-light:
    Label
    Label
    Label
    Label
    charon-dark:
    Label
    Label
    Label
    Label
    nyx-light:
    Label
    Label
    Label
    Label
    nyx-dark:
    Label
    Label
    Label
    Label
    amphiaraus-light:
    Label
    Label
    Label
    Label
    amphiaraus-dark:
    Label
    Label
    Label
    Label
    styx-light:
    Label
    Label
    Label
    Label
    styx-dark:
    Label
    Label
    Label
    Label
    thanatos-light:
    Label
    Label
    Label
    Label
    thanatos-dark:
    Label
    Label
    Label
    Label
    hades-light:
    Label
    Label
    Label
    Label
    hades-dark:
    Label
    Label
    Label
    Label
    asphodel-light:
    Label
    Label
    Label
    Label
    asphodel-dark:
    Label
    Label
    Label
    Label

    Closable

    To use a closable tag, just pass an onClick prop to the Tag component. This will create a pill-shaped tag with a close icon button.

    ClosableClosableClosable

    Primitives

    You can customize the tag by utilizing style props and primitives. A Closable Tag is just a Tag with an IconButton inside.

    ComponentDescription
    TagRootThe root wrapper of the tag.
    Cerberus Forever

    Data Attributes

    The Primitives additionally use the following data attributes for custom styling:

    NameValueDescription
    data-scopetagThe scope of the components.
    data-partrootThe root wrapper of the tag.
    data-palettepalette nameThe color palette of the tag.

    Dynamic Tags

    Sometimes you may want to create Tags based on dynamic variables. In order to do this in a reliable way, we recommend using the Interface pattern.

    Note

    Remember that PandaCSS requires static styles to be known at build time. This is how it can reliably generate atomic styles. See Conditional Styles for more information.

    import { Tag, type TagProps } from '@cerberus/react'
    /**
    * This interface returns palette-based tags in a reliable way that PandaCSS
    * can statically analyze.
    */
    export function MatchPaletteTag(props: TagProps) {
    switch (props.palette) {
    case 'page':
    return <Tag palette="page" {...props} />
    case 'secondaryAction':
    return <Tag palette="secondaryAction" {...props} />
    case 'info':
    return <Tag palette="info" {...props} />
    case 'success':
    return <Tag palette="success" {...props} />
    case 'warning':
    return <Tag palette="warning" {...props} />
    case 'danger':
    return <Tag palette="danger" {...props} />
    default:
    throw new Error(`Unsupported palette: ${props.palette}`)
    }
    }

    API

    Props

    The Tag component is an abstraction of the primitives and accepts the following props:

    NameDefaultDescription
    gradientundefinedThe gradient of the tag (overrides palette).
    palettepageThe color palette of the tag (overrides gradient).
    usagefilledThe style treatment of the tag.
    shapepillThe shape of the tag.
    onClickundefinedHow to create a Closable tag.

    On this page

    • Edit this page on Github
    Cerberus Design System | Docs