---
title: "Checkmark · Base UI — StyleX Blocks"
description: "The standalone checkbox indicator square used by checkbox-style components."
url: "https://stylexblocks.com/components/base-ui/checkmark/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Checkmark

The standalone checkbox indicator square used by checkbox-style components.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/checkmark.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/checkmark.md)
- Category: Form
- Variants: solid, outline, subtle, plain, inverted
- Sizes: xs, sm, md, lg
- HTML page: https://stylexblocks.com/components/base-ui/checkmark/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add checkmark
```

Equivalent: `npx shadcn add @stylexblocks/checkmark`. Registry item JSON: https://stylexblocks.com/r/base-ui/checkmark.json

## Usage

```tsx
import { Checkmark } from "#components/ui/base-ui/checkmark.tsx";
import { indigoPalette } from "@stylexblocks/ui/themes/palettes.ts";

export function Example() {
  return (
    <>
      {/* checked by default — pass checked={false} for the empty box */}
      <Checkmark variant="solid" size="md" palette={indigoPalette} />
      <Checkmark variant="outline" size="md" checked={false} />

      {/* composition: the render prop replaces the underlying element */}
      <Checkmark variant="subtle" render={<li />} />
    </>
  );
}
```

## Source

`components/ui/base-ui/checkmark.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { mergeProps } from "@base-ui/react/merge-props";
import { useRender } from "@base-ui/react/use-render";
import type { StyleOverrideProps } from "#lib/recipe-props.ts";
import { colorPalette } from '@stylexblocks/ui/color-palette.stylex.ts'
import { colors } from '@stylexblocks/ui/tokens/colors.stylex.ts'
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'
import { semanticRadii } from '@stylexblocks/ui/semantic-tokens/radii.stylex.ts'
import { sizes } from '@stylexblocks/ui/tokens/sizes.stylex.ts'
import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'

const checkmarkStyles = stylex.create({
  base: {
    display: 'inline-flex',
    alignItems: 'center',
    justifyContent: 'center',
    flexShrink: 0,
    color: colors.white,
    borderWidth: '1px',
    borderColor: {
      default: 'transparent',
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
    borderRadius: semanticRadii.control,
    outlineWidth: {
      default: null,
      ':focus-visible': '1px',
    },
    outlineOffset: {
      default: null,
      ':focus-visible': '2px',
    },
    outlineStyle: {
      default: null,
      ':focus-visible': 'solid',
    },
    outlineColor: {
      default: null,
      ':focus-visible': colorPalette.focusRing,
    },
    opacity: {
      default: null,
      ':is(:disabled, [disabled], [data-disabled])': 0.5,
    },
  },
})

const checkmarkSizes = stylex.create({
  xs: {
    width: sizes._3,
    height: sizes._3,
  },
  sm: {
    width: sizes._3_5,
    height: sizes._3_5,
  },
  md: {
    width: sizes._4,
    height: sizes._4,
    padding: spacing._0_5,
  },
  lg: {
    width: sizes._5,
    height: sizes._5,
    padding: spacing._0_5,
  },
})

const checkmarkVariants = stylex.create({
  solid: {
    borderColor: {
      default: semanticColors.borderEmphasized,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
  },
  outline: {
    borderColor: {
      default: semanticColors.borderEmphasized,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
  },
  subtle: {
    backgroundColor: colorPalette.muted,
    borderColor: {
      default: colorPalette.emphasized,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
  },
  plain: {},
  inverted: {
    borderColor: {
      default: semanticColors.border,
      ':is([data-invalid], [aria-invalid="true"])': semanticColors.borderError,
    },
    color: colorPalette.fg,
  },
})

export type CheckmarkSize = keyof typeof checkmarkSizes

export type CheckmarkVariant = keyof typeof checkmarkVariants

// Checked styling restated locally — the generated recipe expresses checked
// state as `:checked`, which only matches real form elements, so it is
// applied conditionally from the `checked` prop instead.
const checkmarkChecked = stylex.create({
  solid: {
    backgroundColor: colorPalette.solid,
    borderColor: colorPalette.solid,
    color: colorPalette.contrast,
  },
  outline: { color: colorPalette.fg, borderColor: colorPalette.solid },
  subtle: { color: colorPalette.fg },
  plain: { color: colorPalette.fg },
  inverted: { color: colorPalette.fg },
});

const checkmarkLocal = stylex.create({
  iconFill: { width: "100%", height: "100%" },
});

function CheckIcon() {
  return (
    <svg viewBox="0 0 12 12" fill="none" aria-hidden="true" {...stylex.props(checkmarkLocal.iconFill)}>
      <path
        d="M2.5 6.4 5 8.9l4.5-5.4"
        stroke="currentColor"
        strokeWidth="2"
        strokeLinecap="round"
        strokeLinejoin="round"
      />
    </svg>
  );
}

export interface CheckmarkProps
  extends Omit<useRender.ComponentProps<"span">, "style">,
    StyleOverrideProps {
  variant?: CheckmarkVariant;
  size?: CheckmarkSize;
  checked?: boolean;
}

/**
 * Checkmark — the standalone checkbox indicator square, composed with Base
 * UI's useRender so it stays polymorphic via `render`.
 */
export function Checkmark({
  render,
  variant = "solid",
  size = "md",
  checked = true,
  palette,
  style,
  children,
  ...props
}: CheckmarkProps) {
  return useRender({
    render,
    defaultTagName: "span",
    state: { variant, size, checked },
    props: mergeProps<"span">(
      {
        "aria-hidden": true,
        ...stylex.props(
          palette,
          checkmarkStyles.base,
          checkmarkSizes[size],
          checkmarkVariants[variant],
          checked && checkmarkChecked[variant],
          style,
        ),
        children: checked ? (children ?? <CheckIcon />) : null,
      },
      props,
    ),
  });
}
```
