{"id":16346828,"url":"https://github.com/simonsmith/suitcss-components-form-field","last_synced_at":"2025-07-18T17:08:31.966Z","repository":{"id":54891958,"uuid":"90080007","full_name":"simonsmith/suitcss-components-form-field","owner":"simonsmith","description":"Component CSS for form fields","archived":false,"fork":false,"pushed_at":"2021-01-21T21:11:02.000Z","size":53,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-19T19:48:54.329Z","etag":null,"topics":["component","component-css","component-form","form","suitcss"],"latest_commit_sha":null,"homepage":"https://simonsmith.io/suitcss-components-form-field/test/index.html","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simonsmith.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-02T21:34:11.000Z","updated_at":"2025-02-10T15:09:45.000Z","dependencies_parsed_at":"2022-08-14T05:51:01.731Z","dependency_job_id":null,"html_url":"https://github.com/simonsmith/suitcss-components-form-field","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/simonsmith/suitcss-components-form-field","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fsuitcss-components-form-field","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fsuitcss-components-form-field/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fsuitcss-components-form-field/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fsuitcss-components-form-field/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonsmith","download_url":"https://codeload.github.com/simonsmith/suitcss-components-form-field/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonsmith%2Fsuitcss-components-form-field/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265798722,"owners_count":23829986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["component","component-css","component-form","form","suitcss"],"created_at":"2024-10-11T00:37:41.473Z","updated_at":"2025-07-18T17:08:31.930Z","avatar_url":"https://github.com/simonsmith.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SUIT CSS components-form-field\n\n[![Build Status](https://travis-ci.org/simonsmith/suitcss-components-form-field.svg?branch=master)](https://travis-ci.org/simonsmith/suitcss-components-form-field)\n\nA CSS component for rendering form fields. Ensures inputs, labels and help text\nbehave consistently across browsers.\n\nRead more about [SUIT CSS](https://github.com/suitcss/suit/).\n\n## Installation\n\n* [npm](http://npmjs.org/): `npm install suitcss-components-form-field`\n* Download: [zip](https://github.com/simonsmith/suitcss-components-form-field/releases/latest)\n\n## Example\n\n* [**View a demo**](https://simonsmith.github.io/suitcss-components-form-field/test/demo.html)\n* [**View the tests**](https://simonsmith.github.io/suitcss-components-form-field/test/index.html)\n\n## Available classes\n\n### Component structure\n\n* `FormField` - Containing element. Apply state classes to this\n* `FormField-input` - Consistent rendering of various form inputs\n* `FormField-select` - Used for select elements only (instead of `FormField-input`)\n* `FormField-label` - Label text for the input\n* `FormField-text` - Used to display help text or validation messages\n* `FormField-check` - Wraps around `input` and `label` when using either radio\n  or checkbox inputs\n* `FormField-checkInput` - The `input` class when inside `FormField-check`\n* `FormField-checkLabel` - The `label` when inside `FormField-check`\n\n### States\n\n* `is-error` - Applies the error colours to each element\n* `is-warning` - Applies the warning colours to each element\n* `is-success` - Applies the success colours to each element\n\n## Usage\n\n### Basic\n\nThis works with other inputs such as `textarea`, `range` and `file`.\n\n```html\n\u003cdiv class=\"FormField\"\u003e\n  \u003clabel class=\"FormField-label\" for=\"surname\"\u003eSurname\u003c/label\u003e\n  \u003cinput class=\"FormField-input\" type=\"text\" id=\"surname\" placeholder=\"Enter your surname\"\u003e\n  \u003cp class=\"FormField-text\"\u003eSome optional text to the user about the input field\u003c/p\u003e\n\u003c/div\u003e\n```\n\n### Select elements\n\nSelect elements require their own class name to ensure consistent rendering in\nBlink/Webkit.\n\n```html\n\u003cdiv class=\"FormField\"\u003e\n  \u003clabel class=\"FormField-label\" for=\"select\"\u003eSelect\u003c/label\u003e\n  \u003cselect class=\"FormField-select\"\u003e\n    \u003coption\u003eSome option\u003c/option\u003e\n    \u003coption\u003eAnother option\u003c/option\u003e\n  \u003c/select\u003e\n\u003c/div\u003e\n```\n\n### Using a `label` container\n\n```html\n\u003clabel class=\"FormField\"\u003e\n  \u003cspan class=\"FormField-label\"\u003eSurname\u003c/span\u003e\n  \u003cinput class=\"FormField-input\" type=\"text\" placeholder=\"Enter your surname\"\u003e\n  \u003cp class=\"FormField-text\"\u003eSome text to the user about the input field\u003c/p\u003e\n\u003c/label\u003e\n```\n\n### Checkbox or radio input types\n\nCheckbox and radio inputs require an additional container and different class names.\nThis controls positioning and allows the `FormField-text` to be rendered beneath:\n\n```html\n\u003cdiv class=\"FormField\"\u003e\n  \u003clabel class=\"FormField-check\"\u003e\n    \u003cinput class=\"FormField-checkInput\" name=\"shopping\" type=\"radio\"\u003e\n    \u003cspan class=\"FormField-checkLabel\"\u003eApples\u003c/span\u003e\n  \u003c/label\u003e\n  \u003clabel class=\"FormField-check\"\u003e\n    \u003cinput class=\"FormField-checkInput\" name=\"shopping\" type=\"radio\"\u003e\n    \u003cspan class=\"FormField-checkLabel\"\u003eOranges\u003c/span\u003e\n  \u003c/label\u003e\n  \u003cspan class=\"FormField-text\"\u003eSome text about the choices above\u003c/span\u003e\n\u003c/div\u003e\n```\n\n### Validation states\n\nA state class of `is-error`, `is-success` or `is-warning` can be applied to the\nroot element:\n\n```html\n\u003cdiv class=\"FormField is-error\"\u003e\n  \u003clabel class=\"FormField-label\"\u003eSurname\u003c/label\u003e\n  \u003cinput class=\"FormField-input\" type=\"text\" placeholder=\"Enter your surname\"\u003e\n  \u003cp class=\"FormField-text\"\u003eThere was a problem!\u003c/p\u003e\n\u003c/div\u003e\n```\n\n### Controlling layout\n\n`FormField` leaves the layout concerns to another component or utility, for\nexample [suitcss-components-grid](https://github.com/suitcss/components-grid).\n\n#### Vertical spacing\n\nCan be handled by a component that controls the `\u003cform/\u003e` itself:\n\n```html\n\u003cform class=\"UserForm\"\u003e\n  \u003cdiv class=\"UserForm-field\"\u003e\n    \u003cdiv class=\"FormField\"\u003e\n      // ...\n    \u003c/div\u003e\n  \u003c/div\u003e\n  \u003cdiv class=\"UserForm-field\"\u003e\n    \u003cdiv class=\"FormField\"\u003e\n      // ...\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/form\u003e\n```\n\n#### Horizontal positioning with `Grid` and `utils-size`\n\nThe following achieves an inline form effect\n\n```html\n\u003cdiv class=\"FormField\"\u003e\n  \u003cdiv class=\"Grid Grid--alignMiddle\"\u003e\n    \u003cdiv class=\"Grid-cell u-size2of12\"\u003e\n      \u003clabel class=\"FormField-label u-textBold\"\u003eUsername\u003c/label\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"Grid-cell u-sizeFill\"\u003e\n      \u003cinput class=\"FormField-input\" type=\"text\" value=\"SomeCoolUsername\"\u003e\n      \u003cp class=\"FormField-text\"\u003eThat username is already taken!\u003c/p\u003e\n    \u003c/div\u003e\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n### Configurable variables\n\n#### `FormField-label`\n\n* `--FormField-label-color`\n* `--FormField-label-marginBottom`\n\n#### `FormField-input`\n\n* `--FormField-input-borderColor`\n* `--FormField-input-borderRadius`\n* `--FormField-input-borderWidth`\n* `--FormField-input-color`\n* `--FormField-input-fontFamily`\n* `--FormField-input-fontSize`\n* `--FormField-input-padding`\n\n#### `FormField-text`\n\n* `--FormField-text-fontSize`\n* `--FormField-text-marginTop`\n\n#### `FormField-select`\n\n* `--FormField-select-height`\n\n#### `FormField-check`\n\n* `--FormField-check-gutter` - Space between checkbox/radio and the label\n\n#### Validation states\n\n* `--FormField-input-onDisabled-backgroundColor`\n* `--FormField-onError-color`\n* `--FormField-onWarning-color`\n* `--FormField-onSuccess-color`\n\n## Testing\n\nInstall [Node](http://nodejs.org) (comes with npm).\n\n```\nnpm install\n```\n\nTo generate a build:\n\n```\nnpm run build\n```\n\nTo lint code with [postcss-bem-linter](https://github.com/postcss/postcss-bem-linter) and [stylelint](http://stylelint.io/)\n\n```\nnpm run lint\n```\n\nTo generate the testing build.\n\n```\nnpm run build-test\n```\n\nTo watch the files for making changes to test:\n\n```\nnpm run watch\n```\n\nBasic visual tests are in `test/index.html`.\n\n## Browser support\n\n* Google Chrome (latest)\n* Opera (latest)\n* Firefox (latest)\n* Safari 7.1+\n* Internet Explorer 10+\n* Android 5+ (Chrome 55, Firefox 51)\n* iOS 7+ (Safari)\n* Windows phone 8.1+\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsmith%2Fsuitcss-components-form-field","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonsmith%2Fsuitcss-components-form-field","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonsmith%2Fsuitcss-components-form-field/lists"}