Skip to main content

Input

The sj-input component is a customizable input field for forms.

Props

PropTypeOptionsDefault
variant'outlined' │ 'filled' │ 'flat'outlined, filled, flat'outlined'
type'text' │ 'email' │ 'password' │ 'search' │ 'number' │ 'url'text, email, password, search, number, url'text'
placeholderstring-''
valuestring-''
usePaddingundefined │ 'none' │ 1 │ 2 │ 3 │ 4 │ 'compact' │ 'default' │ 'comfortable' │ 'spacious'undefined, none, 1, 2, 3, 4, compact, default, comfortable, spacious'default'
useRoundedundefined │ 'none' │ 1 │ 2 │ 3 │ 4 │ 'compact' │ 'default' │ 'comfortable' │ 'spacious'undefined, none, 1, 2, 3, 4, compact, default, comfortable, spacious'default'
usePaint'none' │ 'auto' │ 'primary' │ 'secondary' │ 'success' │ 'info' │ 'warning' │ 'error' │ 'dark' │ 'neutral' │ 'light'none, auto, primary, secondary, success, info, warning, error, dark, neutral, light'none'
fullWidthbooleantrue, falsefalse
disabledbooleantrue, falsefalse
invalidbooleantrue, falsefalse
sjSjStyle │ SjStyle[]-undefined

Examples

Variants

<div style="display: flex; flex-direction: column; gap: 0.5rem; width: 320px;">
<sj-input variant="outlined" usePadding="default" useRounded="default" placeholder="Placeholder"></sj-input>
<sj-input variant="filled" usePaint="primary" usePadding="default" useRounded="default" placeholder="Placeholder"></sj-input>
<sj-input variant="flat" placeholder="Placeholder"></sj-input>
</div>

With Prefix/Suffix

<div style="max-width: 360px;">
<sj-input variant="outlined" usePadding="default" useRounded="default" placeholder="Search...">
<sj-icon prefix name="superJson" size="1rem" style="margin-right: 0.25rem"></sj-icon>
<span suffix style="color: neutral.dark">&#64;</span>
</sj-input>
</div>

With Label

<div style="max-width: 360px; display: flex; flex-direction: column; gap: 0.5rem;">
<label for="my-input">Email Address</label>
<sj-input id="my-input" placeholder="Your email"></sj-input>
</div>

With Error Message

<div style="max-width: 360px; display: flex; flex-direction: column; gap: 0.5rem;">
<label for="error-input">Email Address</label>
<sj-input id="error-input" placeholder="Your email" invalid="true" aria-describedby="error-message"></sj-input>
<div id="error-message" style="color: red; font-size: 0.875rem;">This field is required.</div>
</div>