Skip to content
Ginga UI
Ginga UI
日本語

Getting started

  • Overview
  • Quick start
  • Theme generation
  • Custom rendering
  • All components

Forms

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

Display

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

Typography

  • Heading
  • Paragraph

Navigation

  • Anchor

Layout

  • Box

Resources

  • Changelog
  • GitHub (opens in a new tab)

Logo: Twemoji (opens in a new tab) (CC-BY 4.0)

Checkbox

A checkbox that represents a selected state. Supports both single checkboxes and checkbox groups.

View in Storybook (opens in a new tab)

Installation

import { Checkbox } from "@ginga-ui/core";

Basic usage

An example of a single checkbox.

checkbox.tsx
import { Checkbox } from "@ginga-ui/core";

export function BasicExample() {
  return <Checkbox label="I agree to the terms of service" />;
}

Selected

A checkbox that is selected initially.

checkbox.tsx
import { Checkbox } from "@ginga-ui/core";

export function SelectedExample() {
  return <Checkbox label="Selected by default" defaultSelected />;
}

Disabled

An example of a disabled checkbox.

checkbox.tsx
checkbox.module.css
import { Checkbox } from "@ginga-ui/core";
import styles from "./checkbox.module.css";

export function DisabledExample() {
  return (
    <div className={styles.disabledStack}>
      <Checkbox label="Disabled checkbox" disabled />
      <Checkbox label="Disabled and selected" disabled selected />
    </div>
  );
}

Checkbox group

An example of grouping multiple checkboxes.

checkbox.tsx
import { Checkbox, CheckboxGroup } from "@ginga-ui/core";

export function CheckboxGroupExample() {
  return (
    <CheckboxGroup>
      <Checkbox value="option1" label="Option 1" />
      <Checkbox value="option2" label="Option 2" />
      <Checkbox value="option3" label="Option 3" />
    </CheckboxGroup>
  );
}

Props

Checkbox

NameTypeDefaultDescription
labelReactNode-Label of the checkbox. children takes precedence when given.
selectedboolean-Whether the checkbox is checked (controlled). Use it with onChange.
indeterminatebooleanfalseShows the indeterminate state, used when only some of the children are checked.
disabledbooleanfalseDisables the checkbox.
requiredbooleanfalseRequires the checkbox to be checked.
readOnlybooleanfalsePrevents the user from changing the value.
invalidbooleanfalseShows the checkbox as invalid.
iconReactNode-Icon shown when checked.
indeterminateIconReactNode-Icon shown in the indeterminate state.

Also accepts the props of React Aria's Checkbox (opens in a new tab).

CheckboxGroup

NameTypeDefaultDescription
disabledbooleanfalseDisables every checkbox in the group.
requiredbooleanfalseRequires at least one checkbox to be checked.
readOnlybooleanfalsePrevents the user from changing the selection.
invalidbooleanfalseShows the group as invalid.

Also accepts the props of React Aria's CheckboxGroup (opens in a new tab).