DocsBlog
  • 1.4.0

  • light

    dark

    system

    Switch mode
  • Cerberus

    Acheron

    Elysium

Get Started
Components
Data Grid
Signals
Styling
Theming

Concepts

OverviewCompositionCerberus ContextTesting

Layout

Aspect RatioBleedBoxCenterContainerDividerFlexFloatGridGroupLink OverlayScrollableStackWrap

Components

AccordionAdmonitionAvatarButtonCarouselCheckboxClipboardCollapsibleComboboxConfirm ModalCTAModalDate PickerDialogFieldFieldsetFile UploaderIcon ButtonInputLoading StatesMarqueeNotificationsNumber InputPaginationPin InputPopoverProgressPrompt ModalRadioRatingSelectSplit ButtonSwitchTableTabsTagTextTextareaToggleTooltip

Utilities

Client OnlyDownload TriggerEnvironmentFeature FlagsFocus TrapForFormat ByteFormat NumberFormat Relative TimeFrameHighlightJSON Tree ViewLocaleLocal StoragePortalPresenceShowsplitPropsTheme

Tag

Used for categorizing or labeling content

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

Usage

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

Usage Variants

Use the usage prop to change the style of the tag.

options: filled,outlined

Shape Variants

Use the shape prop to change the shape of the tag.

options: pill,square

Colors

You can set the color of the tag by using the palette prop.

Note

By nature of CSS rules, only a `palette` or `gradient` can be used at a time. This is because the `palette` prop sets the background color, and the `gradient` prop sets the background gradient.

options: page,info,success,warning,danger,secondaryAction

Gradients

You can set the gradient of the tag by using the gradient prop.

Note

By nature of CSS rules, only a `palette` or `gradient` can be used at a time. This is because the `palette` prop sets the background color, and the `gradient` prop sets the background gradient.

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.

Customizing

You can customize the Tag using style props and data selectors on any slot primitve.

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.

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.

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

Loading...

Loading...

Loading...

Loading...

FilledStart iconEnd icon
Copy
import { HStack } from '@/styled-system/jsx'
import { Information } from '@carbon/icons-react'
import { Tag } from '@cerberus/react'

export function BasicDemo() {
  return (
    <HStack gap="md">
      <Tag>Filled</Tag>
      <Tag>
        <Information />
        Start icon
      </Tag>
      <Tag>
        End icon
        <Information />
      </Tag>
    </HStack>
  )
}
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
Copy
ClosableClosableClosable
Copy
'use client'

import { HStack } from '@/styled-system/jsx'
import { Tag } from '@cerberus/react'

export function ClosableDemo() {
  const handleClick = () => {
    console.log('Clicked!')
  }

  return (
    <HStack gap="md">
      <Tag onClick={handleClick}>Closable</Tag>

      <Tag palette="info" onClick={handleClick}>
        Closable
      </Tag>

      <Tag palette="danger" onClick={handleClick}>
        Closable
      </Tag>
    </HStack>
  )
}
Cerberus Forever
Copy
import { Tag } from '@cerberus/react'

export function CustomDemo() {
  return (
    <Tag colorPalette="danger" p="2" rounded="0!" transform="skew(-10deg)">
      Cerberus Forever
    </Tag>
  )
}
page:
Label
Label
Label
Label
info:
Label
Label
Label
Label
success:
Label
Label
Label
Label
warning:
Label
Label
Label
Label
danger:
Label
Label
Label
Label
secondaryAction:
Label
Label
Label
Label
Copy
pillsquare
Copy
import { HStack } from '@/styled-system/jsx'
import { For, Tag } from '@cerberus/react'
import { tagShapes } from './data'

export function ShapeDemo() {
  return (
    <HStack gap="md">
      <For each={tagShapes}>
        {(shape) => (
          <Tag key={shape} shape={shape}>
            {shape}
          </Tag>
        )}
      </For>
    </HStack>
  )
}
filledoutlined
Copy
import { HStack } from '@/styled-system/jsx'
import { For, Tag } from '@cerberus/react'
import { tagUsages } from './data'

export function UsageDemo() {
  return (
    <HStack gap="md">
      <For each={tagUsages}>
        {(usage) => (
          <Tag key={usage} usage={usage}>
            {usage}
          </Tag>
        )}
      </For>
    </HStack>
  )
}
import { Grid, GridItem } from '@/styled-system/jsx'
import { Information } from '@carbon/icons-react'
import { Tag, Text } from '@cerberus/react'
import { Fragment } from 'react'
import { tagGradients, variants } from './data'

const GRAD_LIST = tagGradients.map((gradient) => ({ gradient, variants }))

export function GradientDemo() {
  return (
    <Grid columns={5} gap="md" px="lg" w="full">
      {GRAD_LIST.map(({ gradient, variants }) => (
        <Fragment key={`${gradient}`}>
          <Text as="small">{gradient}:</Text>
          {variants.map(({ usage, shape }, idx) => (
            <GridItem key={`${gradient}-${idx}`} colSpan={1}>
              <Tag gradient={gradient} usage={usage} shape={shape}>
                <Information />
                Label
              </Tag>
            </GridItem>
          ))}
        </Fragment>
      ))}
    </Grid>
  )
}
import { Grid, GridItem } from '@/styled-system/jsx'
import { Information } from '@carbon/icons-react'
import { Tag, Text } from '@cerberus/react'
import { Fragment } from 'react'
import { tagPalettes, variants } from './data'

const COLOR_LIST = tagPalettes.map((palette) => ({ palette, variants }))

export function PaletteDemo() {
  return (
    <Grid columns={5} gap="md" px="lg" w="full">
      {COLOR_LIST.map(({ palette, variants }) => (
        <Fragment key={`${palette}`}>
          <Text as="small">{palette}:</Text>
          {variants.map(({ usage, shape }) => (
            <GridItem key={`${palette}:${usage}:${shape}`} colSpan={1}>
              <Tag palette={palette} usage={usage} shape={shape}>
                <Information />
                Label
              </Tag>
            </GridItem>
          ))}
        </Fragment>
      ))}
    </Grid>
  )
}

On this page

  • Usage
  • Usage Variants
  • Shape Variants
  • Colors
  • Gradients
  • Closable
  • Customizing
  • Primitives
  • Data Attributes
  • API
  • Props
  • Edit this page on Github