Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input component label and helper inconsistencies #1977

Open
pekeler opened this issue Jun 18, 2024 · 0 comments
Open

Input component label and helper inconsistencies #1977

pekeler opened this issue Jun 18, 2024 · 0 comments

Comments

@pekeler
Copy link

pekeler commented Jun 18, 2024

I'm building some forms where I sometimes need to place multiple input components in one row. I noticed that

  1. Select has a different margin at the top when labelText is undefined
  2. ComboBox and MultiSelect call it titleText, NumberInput calls it label, while the rest call it labelText
  3. Checkbox, MultiSelect, and RadioButtonGroup are missing helperText

1 is currently the most annoying for us. (The fourth input is the Select) I'd suspect all components don't render the label tag if the value is undefined, except for Select.
image

Example page.svelte:

<script lang="ts">
	import {
		Checkbox,
		Column,
		ComboBox,
		DatePicker,
		DatePickerInput,
		Grid,
		MultiSelect,
		NumberInput,
		PasswordInput,
		RadioButton,
		RadioButtonGroup,
		Row,
		Select,
		SelectItem,
		TextInput
	} from 'carbon-components-svelte';

	let labelText: string | undefined = undefined;
	let helperText: string | undefined = undefined;
</script>

<Select
	labelText="label"
	on:change={(e) => {
		labelText = e.target?.value;
	}}>
	<SelectItem value={undefined} text="(undefined)" />
	<SelectItem value="&nbsp;" text="nbsp" />
	<SelectItem value="Foo" text="Foo" />
</Select>
<Select
	labelText="helper"
	on:change={(e) => {
		helperText = e.target?.value;
	}}>
	<SelectItem value={undefined} text="(undefined)" />
	<SelectItem value="&nbsp;" text="nbsp" />
	<SelectItem value="Foo" text="Foo" />
</Select>
<br />
<br />
<br />
<form>
	<Grid>
		<Row>
			<Column noGutterLeft><TextInput {labelText} {helperText}></TextInput><hr /></Column>
			<Column noGutterLeft><PasswordInput {labelText} {helperText}></PasswordInput><hr /></Column>
			<Column noGutterLeft><NumberInput label={labelText} {helperText} value={0}></NumberInput><hr /></Column>
			<Column noGutterLeft><Select {labelText} {helperText}></Select><hr /></Column>
			<Column noGutterLeft><ComboBox titleText={labelText} {helperText}></ComboBox><hr /></Column>
			<Column noGutterLeft><Checkbox {labelText}></Checkbox><hr /></Column>
			<Column noGutterLeft><DatePicker><DatePickerInput {labelText} {helperText} placeholder="mm/dd/yyyy" /></DatePicker><hr /></Column>
			<Column noGutterLeft><MultiSelect titleText={labelText} label="Select..." items={[]} /><hr /></Column>
			<Column noGutter><RadioButtonGroup legendText={labelText} name="plan" selected="free"><RadioButton labelText="Bar" value="free" /></RadioButtonGroup><hr /></Column>
		</Row>
	</Grid>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant