Hopp til hovedinnhold

Komponenter

Textfield

Textfield gir brukere muligheten til å skrive fritekst eller tall.

className
Description

Classname on the wrapper element `Field`

Type
string
style
Description

Style on the wrapper element `Field`

Type
CSSProperties
Default
undefined
label
Description

Label

Type
ReactNode
description
Description

Description

Type
ReactNode
prefix
Description

Prefix

Type
string
suffix
Description

Suffix

Type
string
error
Description

Error message for field

Type
ReactNode
counter
Description

Uses `Field.Counter` to display a character counter Pass a number to set a limit, or an object to configure the counter

Type
number | FieldCounterProps
aria-label
Description

Defines a string value that labels the current element. @see aria-labelledby.

Type
string
aria-labelledby
Description

Identifies the element (or elements) that labels the current element. @see aria-describedby.

Type
string
multiline
Description

Use to render a `Textarea` instead of `Input` for multiline support

Type
boolean
type
Description

Supported `input` types

Type
"number" | "hidden" | "color" | "date" | "datetime-local" | "email" | "file" | "month" | "password" | "search" | "tel" | "text" | "time" | "url" | "week"
Default
'text'
size
Description

Defines the width of `Input` in count of characters.

Type
number
NameTypeDefaultDescription
classNamestring-

Classname on the wrapper element `Field`

styleCSSPropertiesundefined

Style on the wrapper element `Field`

labelReactNode-

Label

descriptionReactNode-

Description

prefixstring-

Prefix

suffixstring-

Suffix

errorReactNode-

Error message for field

counternumber | FieldCounterProps-

Uses `Field.Counter` to display a character counter Pass a number to set a limit, or an object to configure the counter

aria-labelstring-

Defines a string value that labels the current element. @see aria-labelledby.

aria-labelledbystring-

Identifies the element (or elements) that labels the current element. @see aria-describedby.

multilineboolean-

Use to render a `Textarea` instead of `Input` for multiline support

type"number" | "hidden" | "color" | "date" | "datetime-local" | "email" | "file" | "month" | "password" | "search" | "tel" | "text" | "time" | "url" | "week"'text'

Supported `input` types

sizenumber-

Defines the width of `Input` in count of characters.

Bruk

Eksempel

Med rader

Med prefiks og suffiks

Med teller

HTML

Dette er en samensatt komponent, som bruker Field, Input eller Textarea og Label under panseret.

Siden denne komponenten bygges opp av flere komponenter, anbefaler vi å lese dokumentasjonen for de underliggende komponentene for å få en full oversikt over HTML-strukturen.

CSS variablar og data-attributter

Textfielder en samensatt komponent, med Field, Input eller Textarea og Label.

Her viser vi kun ds-input sine variabler og data-attributter.

CSS-variabler
NavnVerdi
--dsc-input-padding-blockvar(--ds-size-2)
--dsc-input-padding-inlinevar(--ds-size-3)
--dsc-input-paddingvar(--dsc-input-padding-block) var(--dsc-input-padding-inline)
--dsc-input-size--togglevar(--ds-size-6)
--dsc-input-sizevar(--ds-size-12)
--dsc-input-background--readonlyvar(--ds-color-neutral-surface-tinted)
--dsc-input-backgroundvar(--ds-color-neutral-surface-default)
--dsc-input-border-color--readonlyvar(--ds-color-neutral-border-subtle)
--dsc-input-border-colorvar(--ds-color-neutral-border-default)
--dsc-input-border-stylesolid
--dsc-input-border-width--togglemax(var(--ds-border-width-default),calc(var(--ds-size-1)/2))
--dsc-input-border-widthvar(--ds-border-width-default)
--dsc-input-outline-color--hovervar(--ds-color-neutral-border-default)
--dsc-input-outline-color--toggle--hovervar(--dsc-input-accent-color)
--dsc-input-outline-width--hovervar(--ds-border-width-default)
--dsc-input-outline-style--hoversolid
--dsc-input-color--readonlyvar(--ds-color-neutral-text-default)
--dsc-input-colorvar(--ds-color-neutral-text-default)
--dsc-input-stroke-colorvar(--ds-color-base-contrast-default)
--dsc-input-stroke-color--invalidvar(--ds-color-danger-base-contrast-default)
--dsc-input-stroke-width0.05em
--dsc-input-accent-colorvar(--ds-color-base-default)
--dsc-input-accent-color--invalidvar(--ds-color-danger-text-subtle)
--dsc-input-line-heightvar(--ds-line-height-md)
Data-attributter
NavnVerdi
data-widthauto
Rediger denne siden på github.com (åpnes i ny fane)