Skip to content
HomeCobalt

Toggle

A button that stays on or off, such as a filter over a list or a tool in a toolbar.

Examples

Tools above a list of filings, each a toggle that adds one detail to every row.
  • Northgate CreditOct 14
  • Harbor Lane PartnersOct 9
  • Elm Street ValueSep 30
  • Westbrook IncomeSep 26
Filter with a popoverThe grey fill deepens while its popover is open, and turns to ink once a range applies.

26 events

Variants

Look

  • Flood exposure in coastal mortgagesPapers
  • Carbon pricing and bank lendingPapers
PillPill, the grey fill at rest, for a filter over a list among other filters, any number on.

Notes for the quarterly review. *Ask about the move into private credit* before the call with the fund's managers.

PlainToggle, no fill at rest, for a tool in a toolbar that stays pressed while it applies.

Size

Lists

  • Reading list
  • Q3 13F filings
  • Climate risk papers
Small--control-sm tall (32px), for a toggle in a dense row such as a table toolbar.

This week

  • Fund managers forum09:30
  • Credit outlook briefing13:00
  • Quarterly review16:00
Small iconA glyph alone in a square of --control-sm, for a dense header.

States

DisabledBoth looks, off and pressed, at half opacity; a press or a double-click does nothing.
PressedBoth looks pressed, in the ink fill with light text at the same width as off.

Usage

Use it when

  • A filter or an option over content that you turn on and off, and any number can be on. Use Pill.
  • A tool that stays pressed while it applies and is pressed again to stop, such as showing a list's dates, a preview or wrapped lines. Use Toggle, in a toolbar beside the content it changes.

Use something else when

  • Exactly one of several must be pressed. Use SegmentedControl instead, a radio group.
  • The choice navigates to a filtered page. Use ChipRow instead, links that wear pillClasses.
  • The state only applies on Save. Use Checkbox instead; a toggle that waits for Save is a checkbox.
  • The press starts an action. Use Button instead.
  • The control is a setting with two sides that applies at once and is read as on or off, such as notifications. Use Switch instead.
  • The press keeps a thing for later. Use SaveToggle instead.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/toggle.json https://kaanarici.com/r/cobalt/pill.json
import { Toggle, toggleVariants } from "@/components/cobalt/ui/toggle"
import { Pill, pillClasses, pillLabel } from "@/components/cobalt/ui/pill"