Skip to content
Source
Sign inSign up
TanStack/form
Open History to see the last commit

code.tsx

31 lines853 Bytes

1import { splitProps } from 'solid-js'
2import type { JSX } from 'solid-js'
3import { cn } from '@/utils'
4​
5type CodeProps = JSX.HTMLElementTags['code']
6​
7/**
8 * Inline code text styled for identifiers, snippets, and short technical
9 * values.
10 *
11 * @example
12 * ```tsx
13 * <Code>form.handleSubmit()</Code>
14 * ```
15 */
16function Code(props: CodeProps) {
17 const [local, others] = splitProps(props, ['class'])
18​
19 return (
20 <code
21 data-slot="code"
22 class={cn(
23 "border inline-flex w-fit items-center rounded-sm bg-muted px-1 py-0.75 font-mono text-xs font-medium text-foreground in-data-[slot=tooltip-content]:bg-background/20 in-data-[slot=tooltip-content]:text-background dark:in-data-[slot=tooltip-content]:bg-background/10 [&_svg:not([class*='size-'])]:size-3",
24 local.class,
25 )}
26 {...others}
27 />
28 )
30​
31export { Code }