LayerwiseLayerwise
  • Features
  • Pricing
  • Templates
  • Docs
DownloadDownload
FeaturesPricingTemplatesDocsAI Website BuilderVibe CodingPersonal Software
DownloadDownload
  1. Glossary
  2. /
  3. Components

Checkbox

Also called check box or tick box

A small square you tick to turn an option on or select an item, with a dash in a parent box when only some items are checked.

import { useState } from 'react';
import { Checkbox } from '@base-ui/react/checkbox';
import { CheckboxGroup } from '@base-ui/react/checkbox-group';

const FILES = ['Q3 report.pdf', 'Brand guidelines.fig', 'Launch plan.docx'];
const BOX =
  'flex size-5 items-center justify-center rounded-md border bg-background text-white outline-none focus-visible:ring-2 focus-visible:ring-ring data-checked:border-blue-600 data-checked:bg-blue-600 data-indeterminate:border-blue-600 data-indeterminate:bg-blue-600';
// pathLength={1} makes a dash offset of 1 hide the stroke and 0 draw all of it.
const DRAW =
  '[stroke-dasharray:1] [stroke-dashoffset:1] transition-[stroke-dashoffset] duration-180 ease-out group-data-checked:[stroke-dashoffset:0] group-data-indeterminate:hidden';

export function FileSelection() {
  const [selected, setSelected] = useState<string[]>([]);

  return (
    <CheckboxGroup
      value={selected}
      onValueChange={setSelected}
      allValues={FILES}
      aria-label='Files'
      className='w-80 overflow-hidden rounded-xl border text-sm *:flex *:items-center *:gap-3 *:px-4 *:py-2.5 *:not-first:has-[[data-checked]]:bg-blue-500/10'
    >
      <label className='border-b bg-muted font-medium'>
        {/* `parent` ticks every file, and shows a dash when only some are ticked. */}
        <Box parent />
        {selected.length ? `${selected.length} selected` : 'Select all'}
      </label>
      {FILES.map((file) => (
        <label key={file}>
          <Box value={file} />
          {file}
        </label>
      ))}
    </CheckboxGroup>
  );
}

function Box(props: Checkbox.Root.Props) {
  return (
    <Checkbox.Root {...props} className={BOX}>
      <Checkbox.Indicator keepMounted className='group'>
        <svg
          viewBox='0 0 16 16'
          className='size-3.5 fill-none stroke-current stroke-2'
        >
          <path d='M4 8h8' className='hidden group-data-indeterminate:block' />
          <path d='m3.5 8.5 3 3 6-7' pathLength={1} className={DRAW} />
        </svg>
      </Checkbox.Indicator>
    </Checkbox.Root>
  );
}
Add a checkbox to each file row and a Select all checkbox in the header that shows a dash when only some rows are checked. Draw the checkmark in with an SVG stroke animation over 180ms with an ease-out curve, tint checked rows light blue, show an 'N selected' count, and make the whole row clickable with a visible focus ring.

Paste into Layerwise or any AI coding tool.

What is Checkbox?

A checkbox toggles one independent choice: accept the terms, select a file, include weekends. Each box works on its own, so people can check none, one, or all of them. A Select all box above a list shows a third, indeterminate state, drawn as a dash, when only some rows are checked.

Use checkboxes for selecting several items and for options that take effect when someone presses Submit or Save. For a single setting that applies instantly, a toggle switch is clearer, and for picking exactly one option, use radio buttons.

Make the label clickable along with the box, keep the target at least 24px, and show a clear focus ring. The indeterminate state can only be set from JavaScript, through the indeterminate property. A checkmark that draws itself in over about 150 to 200ms, using an SVG stroke animation, makes ticking feel satisfying without slowing anyone down.

Often confused with

Toggle switch
A toggle switch applies one setting the moment you flip it. Checkboxes suit selecting several items or choices that apply when a form is submitted.
Radio button
Radio buttons allow exactly one choice in a group. Checkboxes allow any number, including none.

Related terms

All terms

Toggle switch

An on/off control shaped like a small track with a sliding knob, used for settings that take effect immediately.

Radio button

A round option in a group where choosing one clears the others, so people pick exactly one answer, like a plan or a shipping speed.

SVG line drawing

An animation that makes an SVG outline look like it is being drawn by hand, by revealing its stroke from start to end.

Data table

A table built for working with records: click a column header to sort, type to filter, and check rows to act on several at once.

Build it with Layerwise

Describe your app, watch it run in a live preview, and publish it with a database, storage, and sign-in built in.

DownloadDownloadRead the docs
LayerwiseLayerwise

Build full-stack web apps in minutes with AI.

Product

  • Features
  • Pricing
  • Download
  • Templates

Solutions

  • AI Website Builder
  • Vibe Coding
  • Personal Software

Resources

  • Documentation
  • Changelog
  • Blog
  • Vibe Coding Glossary
  • llms.txt
  • llms-full.txt

Company

  • About
  • Contact

Legal

  • Privacy
  • Analytics Privacy
  • Terms
  • Security
  • Abuse

© 2026 Layerwise. All rights reserved.

Entrances & exits

  • Fade in
  • Slide in
  • Scale in
  • Pop in
  • Blur in
  • Reveal animation
  • Enter and exit animations

Timing & sequencing

  • Duration
  • Delay
  • Keyframes
  • Tweening
  • Stagger
  • Orchestration
  • Fill mode
  • Stepped animation
  • Looping animation
  • Yoyo animation

Easing

  • Easing
  • Linear easing
  • Ease-in
  • Ease-out
  • Ease-in-out
  • Cubic-bezier
  • Asymmetric easing
  • Overshoot easing

Springs & physics

  • Spring animation
  • Stiffness
  • Damping
  • Mass
  • Bounce
  • Velocity
  • Momentum
  • Interruptible animation
  • Rubber-banding

Transforms

  • Translate
  • Scale
  • Rotate
  • Skew
  • 3D flip
  • Perspective
  • Transform origin
  • Origin-aware animation

State transitions

  • Crossfade
  • Morph
  • Shared element transition
  • Layout animation
  • Height auto animation
  • Direction-aware transition
  • Continuity transition
  • Page transition
  • View Transitions API

Scroll effects

  • Scroll reveal
  • Scroll-driven animation
  • Parallax scrolling
  • Scrollytelling
  • Scroll pinning
  • Horizontal scroll section
  • Scroll progress bar
  • Scroll snap
  • Smooth scrolling

Interaction feedback

  • Hover effect
  • Press feedback
  • Ripple effect
  • Shake animation
  • Hold to confirm
  • Drag gesture
  • Drag to reorder
  • Swipe to dismiss
  • Pull to refresh
  • Magnetic button
  • Custom cursor
  • 3D tilt card
  • Spotlight card

Text effects

  • Typewriter effect
  • Text scramble
  • Split text animation
  • Text morph
  • Rotating words
  • Gradient text
  • Shimmer text
  • Number ticker
  • Tabular numbers
  • Underline animation

Loops & ambient motion

  • Marquee
  • Pulse animation
  • Float animation
  • Orbit animation
  • Idle animation
  • Particle background
  • Border beam
  • Confetti
  • Animated gradient

Visual effects

  • Blur
  • Clip-path
  • Mask
  • Before/after slider
  • SVG line drawing
  • Lottie animation

Motion principles

  • Purposeful animation
  • Anticipation
  • Follow-through
  • Squash and stretch
  • Perceived performance
  • Frequency of use
  • Spatial consistency
  • Reduced motion

Animation performance

  • Frame rate (FPS)
  • Jank
  • GPU acceleration
  • will-change
  • Layout thrashing

Layout

  • Hero section
  • Above the fold
  • Sticky header
  • Sidebar
  • Bento grid
  • Card
  • Flexbox
  • CSS Grid
  • Padding vs margin
  • Responsive design
  • Container
  • Masonry layout
  • Split screen
  • Z-index
  • Overflow

Components

  • Button variants
  • Modal
  • Drawer
  • Popover
  • Tooltip
  • Dropdown menu
  • Context menu
  • Toast notification
  • Tabs
  • Segmented control
  • Accordion
  • Carousel
  • Command palette
  • Combobox
  • Toggle switch
  • Checkbox
  • Radio button
  • Date picker
  • Breadcrumb
  • Pagination
  • Infinite scroll
  • Badge
  • Avatar stack
  • Empty state
  • Skeleton screen
  • Spinner
  • Progress bar
  • Data table
  • Stepper
  • Floating label
  • Inline validation
  • Alert banner
  • Tag input

States & patterns

  • Interaction states
  • Focus ring
  • Loading state
  • Optimistic UI
  • Debounce
  • Lazy loading
  • Dark mode
  • Micro-interaction
  • Affordance
  • Undo
  • Drag and drop
  • Keyboard shortcut

Visual styles

  • Glassmorphism
  • Liquid glass
  • Neumorphism
  • Claymorphism
  • Neo-brutalism
  • Skeuomorphism
  • Flat design
  • Mesh gradient
  • Aurora background
  • Grain texture
  • Glow effect
  • Drop shadow
  • Border radius
  • Grid background
  • Typographic hierarchy
  • Accent color
  • Color contrast

Vibe coding & AI

  • Vibe coding
  • Prompt
  • Context window
  • Token
  • AI agent
  • Tool call
  • Hallucination
  • Diff
  • Live preview
  • Checkpoint
  • Git commit
  • Deploy
  • Frontend and backend
  • API
  • Database
  • Rules file
  • MCP
  • Plan mode
  • Visual edit