Introduction Getting Started Child Snippet Ref Transitions Styling Dates Controlled State Figma Migration Guide

Components

Accordion Alert Dialog Aspect Ratio Avatar Button Calendar Checkbox Collapsible Combobox Command Context Menu Date Field Date Picker Date Range Field Date Range Picker Dialog Dropdown Menu Label Link Preview Menubar Navigation Menu Pagination PIN Input Popover Progress Radio Group Range Calendar Scroll Area Select Separator Slider Switch Tabs Toggle Toggle Group Toolbar Tooltip

Utilities

IsUsingKeyboard mergeProps Portal useId

Type Helpers

WithElementRef WithoutChild WithoutChildren WithoutChildrenOrChild

useId

A utility function to generate unique IDs.

The useId function is a utility function that can be used to generate unique IDs. This function is used internally by all Bits UI components and is exposed for your convenience.

Usage

	<script lang="ts">
	import { useId } from "bits-ui";
 
	const id = useId();
</script>
 
<label for={id}>Label here</label>
<input {id} />