Collapsible Search

A button that expands into a pill-shaped search form. Accepts all standard button parameters to configure the trigger appearance.

Default / Medium (md)

@collapsibleSearch([ 'button' => [ 'text' => 'Search', 'icon' => ['name' => 'search'], 'style' => 'filled', 'color' => 'default', 'size' => 'md', ], ]) @endcollapsibleSearch

Small (sm)

@collapsibleSearch([ 'button' => [ 'text' => 'Search', 'icon' => ['name' => 'search'], 'style' => 'filled', 'color' => 'default', 'size' => 'sm', ], ]) @endcollapsibleSearch

Large (lg)

@collapsibleSearch([ 'button' => [ 'text' => 'Search', 'icon' => ['name' => 'search'], 'style' => 'filled', 'color' => 'default', 'size' => 'lg', ], ]) @endcollapsibleSearch

Pre-expanded state

@collapsibleSearch([ 'button' => [ 'text' => 'Search', 'icon' => ['name' => 'search'], 'style' => 'filled', 'color' => 'default', 'size' => 'md', ], 'isExpanded' => true, 'placeholder' => 'Type to search…', ]) @endcollapsibleSearch

Inside a header

Logotype
@collapsibleSearch([ 'button' => [ 'text' => 'Sök', 'icon' => ['name' => 'search'], 'style' => 'basic', 'color' => 'default', 'size' => 'md', 'ariaLabel' => 'Öppna sökfält', 'reversePositions' => true, ], 'placeholder' => 'Vad letar du efter?', 'action' => '/search', ]) @endcollapsibleSearch

Primary colour trigger

@collapsibleSearch([ 'button' => [ 'text' => 'Search', 'icon' => ['name' => 'search'], 'style' => 'filled', 'color' => 'primary', 'size' => 'md', ], ]) @endcollapsibleSearch

API

Parameter Default Description
[] Button component configuration array. Accepts all standard button parameters (text, icon, size, color, style, shape, etc.). Merged directly into the trigger button.
Search… Placeholder text inside the search input.
s Name attribute for the search input (used in query string).
Search Accessible label for the search input.
Form action URL. Defaults to current page.
get Form submission method; get or post.
Close search Accessible label for the close button.
false Render the component in its expanded state on load.
[] Translatable string overrides.

CSS API

Variable Default Type Values Description
var(--base) range - Main unit that drives radius and spacing scales.
var(--border-radius) range - Border Radius
var(--border-width) range - Size
var(--space) range - Base spacing unit. Used for padding and margin inside components.
var(--color--surface) color - Controls the search field background and its readable text contrast.
var(--color--surface-contrast) color - Used for text and icons on surface backgrounds with less contrast.
var(--color--surface-contrast-muted) color - Derived muted contrast for text and icons on surface backgrounds.
var(--color--primary) color - Controls the field outline that separates it from the panel.
var(--color--secondary) color - Controls the surrounding panel and close-button color scheme.
var(--color--secondary-contrast) color - Secondary Contrast
var(--corner-shape) select square, round, squircle, circular, bevel, scoop Corner Shape
var(--font-size-90) range - One step below base in the type scale.
var(--font-size-100) range - Base font size.
var(--font-size-200) range - One step above base in the type scale. Equivalent to h6/subtitle.
20 range - Minimum desktop field width, measured in base units.
40 minmaxrange - Maximum desktop field width, measured in base units.
6 range - Scales the field and its action buttons together, measured in base units.
2 range - Adjusts the field's horizontal inset, measured in space units.
2 range - Scales the field border thickness locally while keeping the search action aligned to its edge.
1 range - A lower value makes the sequence faster; a higher value makes it more deliberate.

Similar components