mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 11:36:36 +00:00
Compare commits
No commits in common. "master" and "v0.63.8" have entirely different histories.
959 changed files with 25870 additions and 54498 deletions
1
.github/FUNDING.yml
vendored
1
.github/FUNDING.yml
vendored
|
@ -1 +0,0 @@
|
||||||
github: metonym
|
|
8
.github/ISSUE_TEMPLATE/config.yml
vendored
8
.github/ISSUE_TEMPLATE/config.yml
vendored
|
@ -1,8 +0,0 @@
|
||||||
blank_issues_enabled: true
|
|
||||||
contact_links:
|
|
||||||
- name: Ask a question
|
|
||||||
url: https://github.com/carbon-design-system/carbon-components-svelte/discussions
|
|
||||||
about: Please ask and answer questions here.
|
|
||||||
- name: Carbon Design System Discord
|
|
||||||
url: https://discord.gg/J7JEUEkTRX
|
|
||||||
about: Chat with us on Discord.
|
|
60
.github/workflows/checks.yml
vendored
60
.github/workflows/checks.yml
vendored
|
@ -1,60 +0,0 @@
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
paths-ignore:
|
|
||||||
- "**.md"
|
|
||||||
- "docs/**"
|
|
||||||
- "examples/**"
|
|
||||||
push:
|
|
||||||
branches: [master]
|
|
||||||
paths-ignore:
|
|
||||||
- "**.md"
|
|
||||||
- "docs/**"
|
|
||||||
- "examples/**"
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
lint:
|
|
||||||
runs-on: macos-15-xlarge
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: actions/setup-node@v5
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "npm"
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run lint
|
|
||||||
|
|
||||||
test:
|
|
||||||
runs-on: macos-15-xlarge
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: actions/setup-node@v5
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "npm"
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run test
|
|
||||||
|
|
||||||
types:
|
|
||||||
runs-on: macos-15-xlarge
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: actions/setup-node@v5
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
cache: "npm"
|
|
||||||
- run: npm ci
|
|
||||||
- run: npm run test:src-types
|
|
||||||
- run: npm run test:types
|
|
||||||
|
|
||||||
deploy-docs:
|
|
||||||
if: github.ref == 'refs/heads/master'
|
|
||||||
needs: [lint, test, types]
|
|
||||||
runs-on: macos-15-xlarge
|
|
||||||
steps:
|
|
||||||
- name: Trigger deploy
|
|
||||||
env:
|
|
||||||
deploy_url: ${{ secrets.RENDER_DEPLOY_HOOK_URL }}
|
|
||||||
run: curl -f "$deploy_url"
|
|
24
.github/workflows/ci.yml
vendored
Normal file
24
.github/workflows/ci.yml
vendored
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches: [master]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
id: yarn-cache
|
||||||
|
with:
|
||||||
|
path: "**/node_modules"
|
||||||
|
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
|
||||||
|
|
||||||
|
- name: Install dependencies and build the library
|
||||||
|
run: |
|
||||||
|
yarn
|
||||||
|
yarn build:lib
|
||||||
|
yarn test:types
|
40
.github/workflows/release.yml
vendored
40
.github/workflows/release.yml
vendored
|
@ -1,40 +0,0 @@
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "v*"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
release:
|
|
||||||
runs-on: macos-latest-xlarge
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
id-token: write
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v5
|
|
||||||
- uses: actions/setup-node@v5
|
|
||||||
with:
|
|
||||||
node-version: 22
|
|
||||||
registry-url: "https://registry.npmjs.org"
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
run: npm install
|
|
||||||
|
|
||||||
- name: Build docs
|
|
||||||
run: npm run build:docs
|
|
||||||
|
|
||||||
- name: Prune package.json
|
|
||||||
run: npx culls --preserve=svelte
|
|
||||||
|
|
||||||
- name: Publish package (stable)
|
|
||||||
if: ${{ ! contains(github.ref, '-next') }}
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
||||||
run: |
|
|
||||||
npm publish --provenance --access public
|
|
||||||
|
|
||||||
- name: Publish package (next)
|
|
||||||
if: ${{ contains(github.ref, '-next') }}
|
|
||||||
env:
|
|
||||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
|
|
||||||
run: |
|
|
||||||
npm publish --provenance --access public --tag next
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
||||||
|
lib
|
||||||
node_modules
|
node_modules
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
|
|
1
.husky/.gitignore
vendored
Normal file
1
.husky/.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
_
|
4
.husky/pre-commit
Executable file
4
.husky/pre-commit
Executable file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/bin/sh
|
||||||
|
. "$(dirname "$0")/_/husky.sh"
|
||||||
|
|
||||||
|
npx lint-staged
|
|
@ -1,9 +1,9 @@
|
||||||
|
/lib
|
||||||
/css
|
/css
|
||||||
/types
|
__sapper__
|
||||||
.svelte-kit
|
.svelte-kit
|
||||||
.routify
|
.routify
|
||||||
dist
|
dist
|
||||||
client
|
client
|
||||||
build
|
build
|
||||||
*.svx
|
*.svx
|
||||||
COMPONENT_API.json
|
|
954
CHANGELOG.md
954
CHANGELOG.md
File diff suppressed because it is too large
Load diff
2978
COMPONENT_INDEX.md
2978
COMPONENT_INDEX.md
File diff suppressed because it is too large
Load diff
|
@ -4,8 +4,8 @@ Before submitting a pull request (PR), consider [filing an issue](https://github
|
||||||
|
|
||||||
## Prerequisites
|
## Prerequisites
|
||||||
|
|
||||||
- [Node.js](https://nodejs.org/en/download/package-manager/) (version >=20)
|
- [Node.js](https://nodejs.org/en/download/package-manager/) (version >=12)
|
||||||
- [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm#using-a-node-installer-to-install-nodejs-and-npm)
|
- [Yarn](https://classic.yarnpkg.com/en/docs/install)
|
||||||
|
|
||||||
## Project set-up
|
## Project set-up
|
||||||
|
|
||||||
|
@ -19,35 +19,42 @@ cd carbon-components-svelte
|
||||||
Set the original repository as the upstream:
|
Set the original repository as the upstream:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
git remote add upstream git@github.com:carbon-design-system/carbon-components-svelte.git
|
git remote add upstream git@github.com:IBM/carbon-components-svelte.git
|
||||||
# verify that the upstream is added
|
# verify that the upstream is added
|
||||||
git remote -v
|
git remote -v
|
||||||
```
|
```
|
||||||
|
|
||||||
### Install
|
### Install
|
||||||
|
|
||||||
Install the project dependencies.
|
Install the project dependencies:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm install
|
# carbon-components-svelte/
|
||||||
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
## Documentation set-up
|
## Documentation set-up
|
||||||
|
|
||||||
Component documentation is located in the `docs` folder. The website is built using svite, routify, and MDsveX. You will need to create a symbolic project link in order to see live changes reflected when developing locally.
|
Component documentation is located in the `docs` folder. The website is built using svite, routify, and MDsveX. You will need to create a symbolic project link in order to see live changes reflected when developing locally.
|
||||||
|
|
||||||
First, create a symbolic link at the root of the project:
|
First, create a symbolic link at the root of the project folder:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm link
|
# carbon-components-svelte/
|
||||||
|
yarn link
|
||||||
```
|
```
|
||||||
|
|
||||||
Then, go into `docs` and link the package.
|
Go into the `docs` folder:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
cd docs
|
cd docs
|
||||||
npm link "carbon-components-svelte"
|
```
|
||||||
npm install
|
|
||||||
|
Link `"carbon-components-svelte"`:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
yarn link "carbon-components-svelte"
|
||||||
|
yarn install
|
||||||
```
|
```
|
||||||
|
|
||||||
If linked correctly, any change to a component in the `src` folder should be reflected in the `docs` site.
|
If linked correctly, any change to a component in the `src` folder should be reflected in the `docs` site.
|
||||||
|
@ -67,10 +74,10 @@ Preview changes to components from the `src` folder in the documentation website
|
||||||
In the `docs` folder, run:
|
In the `docs` folder, run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run dev
|
yarn dev
|
||||||
```
|
```
|
||||||
|
|
||||||
The site should be served at http://localhost:5173/ (or the next available port).
|
The site should be served at `http://localhost:3000/` (or the next available port).
|
||||||
|
|
||||||
### Component Format
|
### Component Format
|
||||||
|
|
||||||
|
@ -114,12 +121,13 @@ export {
|
||||||
} from "./ComposedModal";
|
} from "./ComposedModal";
|
||||||
```
|
```
|
||||||
|
|
||||||
### Run `npm run build:docs`
|
### Run `yarn build:docs`
|
||||||
|
|
||||||
Run the following command to re-generate TypeScript definitions and documentation.
|
Run the following command to re-generate TypeScript definitions and documentation.
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
npm run build:docs
|
# carbon-components-svelte/
|
||||||
|
yarn build:docs
|
||||||
```
|
```
|
||||||
|
|
||||||
## Submit a Pull Request
|
## Submit a Pull Request
|
||||||
|
@ -137,51 +145,3 @@ git merge upstream/master
|
||||||
### Submit a PR
|
### Submit a PR
|
||||||
|
|
||||||
After you've pushed your changes to remote, submit your PR. Make sure you are comparing `<YOUR_USER_ID>/feature` to `origin/master`.
|
After you've pushed your changes to remote, submit your PR. Make sure you are comparing `<YOUR_USER_ID>/feature` to `origin/master`.
|
||||||
|
|
||||||
## Maintainer guide
|
|
||||||
|
|
||||||
The following items only apply to project maintainers.
|
|
||||||
|
|
||||||
### Release
|
|
||||||
|
|
||||||
This library is published to NPM with [provenance](https://docs.npmjs.com/generating-provenance-statements) via a [GitHub workflow](https://github.com/carbon-design-system/carbon-components-svelte/blob/master/.github/workflows/release.yml).
|
|
||||||
|
|
||||||
The workflow is automatically triggered when pushing a tag that begins with `v` (e.g., `v0.81.1`).
|
|
||||||
|
|
||||||
However, maintainers must perform a few things in preparation for a release.
|
|
||||||
|
|
||||||
Locally, while on `master` and the branch is clean, run `npm run release`. This command will:
|
|
||||||
|
|
||||||
- Bump the semantic version in `package.json`
|
|
||||||
- Generate notes in `CHANGELOG.md`
|
|
||||||
- Run `npm run build:docs` to update the generated documentation
|
|
||||||
|
|
||||||
This command will not create a commit nor tag. Afterwards, perform the following manually:
|
|
||||||
|
|
||||||
```sh
|
|
||||||
# 1. Commit the changes using the new version as the commit message.
|
|
||||||
git commit -am "v0.81.1"
|
|
||||||
|
|
||||||
# 2. Create a tag.
|
|
||||||
git tag v0.81.1
|
|
||||||
|
|
||||||
# 3. Push the tag to the remote.
|
|
||||||
# This will trigger the `release.yml` workflow to publish a new package to NPM (with provenance).
|
|
||||||
git push origin v0.81.1
|
|
||||||
```
|
|
||||||
|
|
||||||
If all goes as expected, the [`release.yml` workflow](https://github.com/carbon-design-system/carbon-components-svelte/actions/workflows/release.yml) should trigger a new run and publish the new version to NPM.
|
|
||||||
|
|
||||||
### Post-release checklist
|
|
||||||
|
|
||||||
After confirming that the new release is published to NPM, perform the following:
|
|
||||||
|
|
||||||
1. Create a [new release](https://github.com/carbon-design-system/carbon-components-svelte/releases/new) on GitHub. Click "Generate release notes" to automatically list changes by commit with the relevant Pull Request and author metadata. You may manually remove notes that are not relevant to the release (e.g., CI changes).
|
|
||||||
|
|
||||||
2. Publish the release as the latest release.
|
|
||||||
|
|
||||||
3. As good practice, visit the Pull Request and/or issue for each commit and manually confirm that it's been released. This is helpful for future readers to understand what version includes the new feature or fix.
|
|
||||||
|
|
||||||
```md
|
|
||||||
Released in [v0.81.1](https://github.com/carbon-design-system/carbon-components-svelte/releases/tag/v0.81.1).
|
|
||||||
```
|
|
||||||
|
|
180
README.md
180
README.md
|
@ -1,11 +1,8 @@
|
||||||
# carbon-components-svelte
|
# carbon-components-svelte
|
||||||
|
|
||||||
[![NPM][npm]][npm-url]
|
[![NPM][npm]][npm-url]
|
||||||

|

|
||||||

|

|
||||||
<a href="https://discord.gg/J7JEUEkTRX">
|
|
||||||
<img src="https://img.shields.io/discord/689212587170201628?color=5865F2&style=for-the-badge" alt="Chat with us on Discord">
|
|
||||||
</a>
|
|
||||||
|
|
||||||
Carbon Components Svelte is a [Svelte](https://github.com/sveltejs/svelte) component library that implements the [Carbon Design System](https://github.com/carbon-design-system), an open source design system by IBM.
|
Carbon Components Svelte is a [Svelte](https://github.com/sveltejs/svelte) component library that implements the [Carbon Design System](https://github.com/carbon-design-system), an open source design system by IBM.
|
||||||
|
|
||||||
|
@ -13,12 +10,16 @@ Design systems facilitate design and development through reuse, consistency, and
|
||||||
|
|
||||||
The Carbon Svelte portfolio also includes:
|
The Carbon Svelte portfolio also includes:
|
||||||
|
|
||||||
- **[Carbon Icons Svelte](https://github.com/carbon-design-system/carbon-icons-svelte)**: 2,500+ Carbon icons as Svelte components
|
- **[Carbon Icons Svelte](https://github.com/carbon-design-system/carbon-icons-svelte)**: 1900+ Carbon icons as Svelte components
|
||||||
- **[Carbon Pictograms Svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)**: 1,300+ Carbon pictograms as Svelte components
|
- **[Carbon Pictograms Svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)**: 700+ Carbon pictograms as Svelte components
|
||||||
- **[Carbon Charts Svelte](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte)**: 25+ charts, powered by d3
|
- **[Carbon Charts Svelte](https://github.com/carbon-design-system/carbon-charts/tree/master/packages/svelte)**: 20+ charts, powered by d3
|
||||||
- **[Carbon Preprocess Svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte)**: Collection of Svelte preprocessors for Carbon
|
- **[Carbon Preprocess Svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte)**: Collection of Svelte preprocessors for Carbon
|
||||||
|
|
||||||
## [Documentation](https://svelte.carbondesignsystem.com)
|
## [Documentation](https://carbon-components-svelte.onrender.com)
|
||||||
|
|
||||||
|
The documentation site is deployed to [Render](https://render.com) as a Static Site. See [render.yaml](render.yaml) for details.
|
||||||
|
|
||||||
|
[](https://render.com/deploy?repo=https://github.com/carbon-design-system/carbon-components-svelte)
|
||||||
|
|
||||||
Other forms of documentation are auto-generated:
|
Other forms of documentation are auto-generated:
|
||||||
|
|
||||||
|
@ -28,18 +29,24 @@ Other forms of documentation are auto-generated:
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
Install `carbon-components-svelte` as a development dependency.
|
||||||
|
|
||||||
|
**Yarn**
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# npm
|
yarn add -D carbon-components-svelte
|
||||||
npm i carbon-components-svelte
|
```
|
||||||
|
|
||||||
# pnpm
|
**NPM**
|
||||||
pnpm i carbon-components-svelte
|
|
||||||
|
|
||||||
# Yarn
|
```sh
|
||||||
yarn add carbon-components-svelte
|
npm i -D carbon-components-svelte
|
||||||
|
```
|
||||||
|
|
||||||
# Bun
|
**pnpm**
|
||||||
bun add carbon-components-svelte
|
|
||||||
|
```sh
|
||||||
|
pnpm i -D carbon-components-svelte
|
||||||
```
|
```
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
@ -55,7 +62,7 @@ Before importing components, you will need to first apply Carbon component style
|
||||||
- **g100.css**: Gray 100 theme (dark)
|
- **g100.css**: Gray 100 theme (dark)
|
||||||
- **all.css**: All themes (White, Gray 10, Gray 90, Gray 100) using [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
|
- **all.css**: All themes (White, Gray 10, Gray 90, Gray 100) using [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties)
|
||||||
|
|
||||||
Each StyleSheet is [generated](scripts/build-css.js) from the flagship [carbon-components](https://github.com/carbon-design-system/carbon/tree/main/packages/carbon-components) library.
|
Each StyleSheet is [generated](scripts/build-css.js) from the flagship [carbon-components](https://github.com/carbon-design-system/carbon/tree/master/packages/components) library.
|
||||||
|
|
||||||
The compiled CSS is generated from the following `.scss` files:
|
The compiled CSS is generated from the following `.scss` files:
|
||||||
|
|
||||||
|
@ -88,11 +95,42 @@ import "carbon-components-svelte/css/g100.css";
|
||||||
import "carbon-components-svelte/css/all.css";
|
import "carbon-components-svelte/css/all.css";
|
||||||
```
|
```
|
||||||
|
|
||||||
|
#### CDN
|
||||||
|
|
||||||
|
An alternative to loading styles is to link an external StyleSheet from a Content Delivery Network (CDN) like [unpkg.com](https://unpkg.com/).
|
||||||
|
|
||||||
|
This is best suited for rapid prototyping.
|
||||||
|
|
||||||
|
##### HTML
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/carbon-components-svelte/css/white.css"
|
||||||
|
/>
|
||||||
|
</head>
|
||||||
|
</html>
|
||||||
|
```
|
||||||
|
|
||||||
|
##### `svelte:head`
|
||||||
|
|
||||||
|
```html
|
||||||
|
<svelte:head>
|
||||||
|
<link
|
||||||
|
rel="stylesheet"
|
||||||
|
href="https://unpkg.com/carbon-components-svelte/css/white.css"
|
||||||
|
/>
|
||||||
|
</svelte:head>
|
||||||
|
```
|
||||||
|
|
||||||
### SCSS
|
### SCSS
|
||||||
|
|
||||||
The most performant method to load styles is to import SCSS directly from carbon-components. Although it requires more set up, you can reduce the size of the bundle CSS by importing individual component styles instead of a pre-compiled CSS StyleSheet.
|
The most performant method to load styles is to import SCSS directly from carbon-components. Although it requires more set up, you can reduce the size of the bundle CSS by importing individual component styles instead of a pre-compiled CSS StyleSheet.
|
||||||
|
|
||||||
Refer to the [official Carbon guide on SASS](https://github.com/carbon-design-system/carbon/blob/v10/docs/guides/sass.md) for documentation.
|
Refer to the [official Carbon guide on SASS](https://github.com/carbon-design-system/carbon/blob/main/docs/guides/sass.md) for documentation.
|
||||||
|
|
||||||
### Dynamic theming
|
### Dynamic theming
|
||||||
|
|
||||||
|
@ -105,7 +143,7 @@ import "carbon-components-svelte/css/all.css";
|
||||||
Update the theme by setting the `theme` attribute on the `html` element. The default `theme` is `"white"`.
|
Update the theme by setting the `theme` attribute on the `html` element. The default `theme` is `"white"`.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!doctype html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" theme="g10">
|
<html lang="en" theme="g10">
|
||||||
<body>
|
<body>
|
||||||
...
|
...
|
||||||
|
@ -125,7 +163,7 @@ Programmatically switch between each of the five Carbon themes by setting the "t
|
||||||
|
|
||||||
### Importing components
|
### Importing components
|
||||||
|
|
||||||
Import components from `carbon-components-svelte` in the `script` tag of your Svelte file. Visit the [documentation site](https://svelte.carbondesignsystem.com) for examples.
|
Import components from `carbon-components-svelte` in the `script` tag of your Svelte file. Visit the [documentation site](https://carbon-components-svelte.onrender.com) for examples.
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<!-- App.svelte -->
|
<!-- App.svelte -->
|
||||||
|
@ -142,30 +180,31 @@ Import components from `carbon-components-svelte` in the `script` tag of your Sv
|
||||||
|
|
||||||
**Refer to [COMPONENT_INDEX.md](COMPONENT_INDEX.md) for component API documentation.**
|
**Refer to [COMPONENT_INDEX.md](COMPONENT_INDEX.md) for component API documentation.**
|
||||||
|
|
||||||
## Preprocessors & Plugins
|
## Preprocessors
|
||||||
|
|
||||||
[carbon-preprocess-svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte) is a collection of Svelte preprocessors for Carbon.
|
[carbon-preprocess-svelte](https://github.com/carbon-design-system/carbon-preprocess-svelte) is a collection of Svelte preprocessors for Carbon.
|
||||||
|
|
||||||
> [!NOTE]
|
**Yarn**
|
||||||
> Using `carbon-preprocess-svelte` is optional and not a prerequisite for this library. It should be installed as a development dependency.
|
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
# npm
|
|
||||||
npm i -D carbon-preprocess-svelte
|
|
||||||
|
|
||||||
# pnpm
|
|
||||||
pnpm i -D carbon-preprocess-svelte
|
|
||||||
|
|
||||||
# Yarn
|
|
||||||
yarn add -D carbon-preprocess-svelte
|
yarn add -D carbon-preprocess-svelte
|
||||||
|
```
|
||||||
|
|
||||||
# Bun
|
**NPM**
|
||||||
bun add -D carbon-preprocess-svelte
|
|
||||||
|
```sh
|
||||||
|
npm i -D carbon-preprocess-svelte
|
||||||
|
```
|
||||||
|
|
||||||
|
**pnpm**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
pnpm i -D carbon-preprocess-svelte
|
||||||
```
|
```
|
||||||
|
|
||||||
### `optimizeImports`
|
### `optimizeImports`
|
||||||
|
|
||||||
`optimizeImports` is a Svelte preprocessor that rewrites barrel imports from Carbon components/icons/pictograms packages to their source Svelte code paths. This can significantly speed up development and production build compile times while preserving typeahead and autocompletion offered by integrated development environments (IDE) like VS Code.
|
`optimizeImports` is a script preprocessor that rewrites base imports from Carbon components/icons/pictograms packages to their source Svelte code paths. This can greatly speed up compile times during development while preserving typeahead and autocompletion hinting offered by integrated development environments (IDE) like VSCode.
|
||||||
|
|
||||||
The preprocessor optimizes imports from the following packages:
|
The preprocessor optimizes imports from the following packages:
|
||||||
|
|
||||||
|
@ -173,23 +212,19 @@ The preprocessor optimizes imports from the following packages:
|
||||||
- [carbon-icons-svelte](https://github.com/carbon-design-system/carbon-icons-svelte)
|
- [carbon-icons-svelte](https://github.com/carbon-design-system/carbon-icons-svelte)
|
||||||
- [carbon-pictograms-svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)
|
- [carbon-pictograms-svelte](https://github.com/carbon-design-system/carbon-pictograms-svelte)
|
||||||
|
|
||||||
**Before & After**
|
**Example**
|
||||||
|
|
||||||
```diff
|
```diff
|
||||||
- import { Button } from "carbon-components-svelte";
|
- import { Button } from "carbon-components-svelte";
|
||||||
+ import Button from "carbon-components-svelte/src/Button/Button.svelte";
|
- import { Add16 } from "carbon-icons-svelte";
|
||||||
|
|
||||||
- import { Add } from "carbon-icons-svelte";
|
|
||||||
+ import Add from "carbon-icons-svelte/lib/Add.svelte";
|
|
||||||
|
|
||||||
- import { Airplane } from "carbon-pictograms-svelte";
|
- import { Airplane } from "carbon-pictograms-svelte";
|
||||||
|
+ import Button from "carbon-components-svelte/src/Button/Button.svelte";
|
||||||
|
+ import Add16 from "carbon-icons-svelte/lib/Add16.svelte";
|
||||||
+ import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
|
+ import Airplane from "carbon-pictograms-svelte/lib/Airplane.svelte";
|
||||||
```
|
```
|
||||||
|
|
||||||
#### Usage
|
#### Usage
|
||||||
|
|
||||||
See [examples](examples) for full configurations.
|
|
||||||
|
|
||||||
```js
|
```js
|
||||||
// svelte.config.js
|
// svelte.config.js
|
||||||
import { optimizeImports } from "carbon-preprocess-svelte";
|
import { optimizeImports } from "carbon-preprocess-svelte";
|
||||||
|
@ -199,62 +234,11 @@ export default {
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
Any other preprocessors that transpile code in the `script` block should be invoked before `optimizeImports`.
|
|
||||||
|
|
||||||
For example, `vitePreprocess` should precede `optimizeImports`.
|
|
||||||
|
|
||||||
```diff
|
|
||||||
// svelte.config.js
|
|
||||||
+ import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
|
|
||||||
import { optimizeImports } from "carbon-preprocess-svelte";
|
|
||||||
|
|
||||||
export default {
|
|
||||||
preprocess: [
|
|
||||||
+ vitePreprocess(),
|
|
||||||
optimizeImports()
|
|
||||||
],
|
|
||||||
};
|
|
||||||
```
|
|
||||||
|
|
||||||
### `optimizeCss`
|
|
||||||
|
|
||||||
`optimizeCss` is a Vite plugin that removes unused Carbon styles at build time. The plugin is compatible with Rollup ([Vite](https://vitejs.dev/guide/api-plugin) extends the Rollup plugin API).
|
|
||||||
|
|
||||||
`carbon-components-svelte@0.85.0` or greater is required.
|
|
||||||
|
|
||||||
```diff
|
|
||||||
$ vite build
|
|
||||||
|
|
||||||
Optimized index-CU4gbKFa.css
|
|
||||||
- Before: 606.26 kB
|
|
||||||
+ After: 53.22 kB (-91.22%)
|
|
||||||
|
|
||||||
dist/index.html 0.34 kB │ gzip: 0.24 kB
|
|
||||||
dist/assets/index-CU4gbKFa.css 53.22 kB │ gzip: 6.91 kB
|
|
||||||
dist/assets/index-Ceijs3eO.js 53.65 kB │ gzip: 15.88 kB
|
|
||||||
```
|
|
||||||
|
|
||||||
> [!NOTE]
|
|
||||||
> This is a plugin and not a Svelte preprocessor. It should be added to the list of `vite.plugins`. For Vite set-ups, this plugin is only run when building the app. For Rollup and Webpack, you should conditionally apply the plugin to only execute when building for production.
|
|
||||||
|
|
||||||
#### Usage
|
|
||||||
|
|
||||||
See [examples](examples) for full configurations.
|
|
||||||
|
|
||||||
```js
|
|
||||||
// vite.config.js
|
|
||||||
import { sveltekit } from "@sveltejs/kit/vite";
|
|
||||||
import { optimizeCss } from "carbon-preprocess-svelte";
|
|
||||||
import { defineConfig } from "vite";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
plugins: [sveltekit(), optimizeCss()],
|
|
||||||
});
|
|
||||||
```
|
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
- [examples/rollup](examples/rollup/)
|
- [examples/rollup](examples/rollup/)
|
||||||
|
- [examples/sapper](examples/sapper/)
|
||||||
|
- [examples/snowpack](examples/snowpack/)
|
||||||
- [examples/sveltekit](examples/sveltekit/)
|
- [examples/sveltekit](examples/sveltekit/)
|
||||||
- [examples/vite](examples/vite/)
|
- [examples/vite](examples/vite/)
|
||||||
- [examples/webpack](examples/webpack/)
|
- [examples/webpack](examples/webpack/)
|
||||||
|
@ -275,11 +259,3 @@ Refer to the [Contributing guidelines](CONTRIBUTING.md).
|
||||||
|
|
||||||
[npm]: https://img.shields.io/npm/v/carbon-components-svelte.svg?color=262626&style=for-the-badge
|
[npm]: https://img.shields.io/npm/v/carbon-components-svelte.svg?color=262626&style=for-the-badge
|
||||||
[npm-url]: https://npmjs.com/package/carbon-components-svelte
|
[npm-url]: https://npmjs.com/package/carbon-components-svelte
|
||||||
|
|
||||||
## <picture><source height="20" width="20" media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-dark.svg"><source height="20" width="20" media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"><img height="20" width="20" alt="IBM Telemetry" src="https://raw.githubusercontent.com/ibm-telemetry/telemetry-js/main/docs/images/ibm-telemetry-light.svg"></picture> IBM Telemetry
|
|
||||||
|
|
||||||
This package uses IBM Telemetry to collect de-identified and anonymized metrics data in CI environments. By installing
|
|
||||||
this package as a dependency you are agreeing to telemetry collection. To opt out, see
|
|
||||||
[Opting out of IBM Telemetry data collection](https://github.com/ibm-telemetry/telemetry-js/tree/main#opting-out-of-ibm-telemetry-data-collection).
|
|
||||||
For more information on the data being collected, please see the
|
|
||||||
[IBM Telemetry documentation](https://github.com/ibm-telemetry/telemetry-js/tree/main#ibm-telemetry-collection-basics).
|
|
||||||
|
|
32
SECURITY.md
32
SECURITY.md
|
@ -1,32 +0,0 @@
|
||||||
# Security Policy
|
|
||||||
|
|
||||||
## Supported Versions
|
|
||||||
|
|
||||||
| Version | Supported |
|
|
||||||
| ------- | ------------------ |
|
|
||||||
| 0.x | :white_check_mark: |
|
|
||||||
|
|
||||||
## Reporting a Vulnerability
|
|
||||||
|
|
||||||
_Please do not report security vulnerabilities through public GitHub issues._
|
|
||||||
|
|
||||||
Instead, report a vulnerability through GitHub's security advisory feature at
|
|
||||||
https://github.com/carbon-design-system/carbon-components-svelte/security/advisories/new
|
|
||||||
|
|
||||||
Please include a description of the issue, the steps you took to create the
|
|
||||||
issue, affected versions, and, if known, mitigations for the issue. Our team
|
|
||||||
aims to respond to all new vulnerability reports within 7 business days.
|
|
||||||
|
|
||||||
Additional information on reporting vulnerabilities to IBM is available at
|
|
||||||
https://www.ibm.com/trust/security-psirt
|
|
||||||
|
|
||||||
## Preferred languages
|
|
||||||
|
|
||||||
We prefer all communications to be in English.
|
|
||||||
|
|
||||||
## Comments on this policy
|
|
||||||
|
|
||||||
If you have suggestions on how this process could be improved please
|
|
||||||
[submit a pull request](https://github.com/carbon-design-system/carbon-components-svelte/compare)
|
|
||||||
or [file an issue](https://github.com/carbon-design-system/carbon-components-svelte/issues/new) to
|
|
||||||
discuss.
|
|
190
carbon.yml
190
carbon.yml
|
@ -1,48 +1,10 @@
|
||||||
# yaml-language-server: $schema=https://unpkg.com/@carbon-platform/schemas@v1/carbon-resources.schema.json
|
# yaml-language-server: $schema=https://unpkg.com/@carbon-platform/schemas@v1/carbon-resources.schema.json
|
||||||
library:
|
library:
|
||||||
id: carbon-components-svelte
|
id: carbon-components-svelte
|
||||||
name: Carbon Svelte
|
name: Carbon Components Svelte
|
||||||
description: Build user interfaces with Carbon's core components.
|
description: Svelte implementation of Carbon Components.
|
||||||
externalDocsUrl: https://svelte.carbondesignsystem.com
|
externalDocsUrl: https://carbon-components-svelte.onrender.com
|
||||||
inherits: carbon-styles
|
inherits: carbon-styles
|
||||||
navData:
|
|
||||||
- title: Get started
|
|
||||||
path: "https://github.com/carbon-design-system/carbon-website/blob/carbon-platform/src/pages/developing/frameworks/svelte.mdx"
|
|
||||||
designKits:
|
|
||||||
carbon-white-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-white-sketch
|
|
||||||
carbon-g10-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g10-sketch
|
|
||||||
carbon-g90-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g90-sketch
|
|
||||||
carbon-g100-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g100-sketch
|
|
||||||
carbon-shell-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-shell-sketch
|
|
||||||
carbon-white-adobe-xd:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-white-adobe-xd
|
|
||||||
carbon-g10-adobe-xd:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g10-adobe-xd
|
|
||||||
carbon-g90-adobe-xd:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g90-adobe-xd
|
|
||||||
carbon-g100-adobe-xd:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g100-adobe-xd
|
|
||||||
axure-widget-library:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/axure-widget-library
|
|
||||||
text-toolbar-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/text-toolbar-sketch
|
|
||||||
carbon-mid-fi-sketch:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-mid-fi-sketch
|
|
||||||
carbon-wireframe-invision-freehand:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-wireframe-invision-freehand
|
|
||||||
carbon-white-figma:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-white-figma
|
|
||||||
carbon-g10-figma:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g10-figma
|
|
||||||
carbon-g90-figma:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g90-figma
|
|
||||||
carbon-g100-figma:
|
|
||||||
$ref: https://unpkg.com/@carbon-platform/resources/carbon.yml#/designKits/carbon-g100-figma
|
|
||||||
assets:
|
assets:
|
||||||
accordion:
|
accordion:
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -52,7 +14,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Accordion
|
url: https://carbon-components-svelte.onrender.com/components/Accordion
|
||||||
aspect-ratio:
|
aspect-ratio:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -60,7 +22,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/AspectRatio
|
url: https://carbon-components-svelte.onrender.com/components/AspectRatio
|
||||||
breadcrumb:
|
breadcrumb:
|
||||||
status: stable
|
status: stable
|
||||||
externalDocsUrl: https://www.carbondesignsystem.com/components/breadcrumb/usage
|
externalDocsUrl: https://www.carbondesignsystem.com/components/breadcrumb/usage
|
||||||
|
@ -69,7 +31,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Breadcrumb
|
url: https://carbon-components-svelte.onrender.com/components/Breadcrumb
|
||||||
breakpoint:
|
breakpoint:
|
||||||
name: Breakpoint
|
name: Breakpoint
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -81,7 +43,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Breakpoint
|
url: https://carbon-components-svelte.onrender.com/components/Breakpoint
|
||||||
tags:
|
tags:
|
||||||
- shell
|
- shell
|
||||||
button:
|
button:
|
||||||
|
@ -92,7 +54,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Button
|
url: https://carbon-components-svelte.onrender.com/components/Button
|
||||||
button-set:
|
button-set:
|
||||||
name: Button set
|
name: Button set
|
||||||
description: Buttons in a button set are juxtaposed by default.
|
description: Buttons in a button set are juxtaposed by default.
|
||||||
|
@ -105,7 +67,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ButtonSet
|
url: https://carbon-components-svelte.onrender.com/components/ButtonSet
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
checkbox:
|
checkbox:
|
||||||
|
@ -116,7 +78,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Checkbox
|
url: https://carbon-components-svelte.onrender.com/components/Checkbox
|
||||||
clickable-tile:
|
clickable-tile:
|
||||||
name: Clickable tile
|
name: Clickable tile
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -128,7 +90,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ClickableTile
|
url: https://carbon-components-svelte.onrender.com/components/ClickableTile
|
||||||
tags:
|
tags:
|
||||||
- contextual-navigation
|
- contextual-navigation
|
||||||
code-snippet:
|
code-snippet:
|
||||||
|
@ -139,7 +101,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/CodeSnippet
|
url: https://carbon-components-svelte.onrender.com/components/CodeSnippet
|
||||||
combo-box:
|
combo-box:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -147,7 +109,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ComboBox
|
url: https://carbon-components-svelte.onrender.com/components/ComboBox
|
||||||
composed-modal:
|
composed-modal:
|
||||||
name: Composed modal
|
name: Composed modal
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -159,7 +121,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ComposedModal
|
url: https://carbon-components-svelte.onrender.com/components/ComposedModal
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
content-switcher:
|
content-switcher:
|
||||||
|
@ -170,7 +132,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ContentSwitcher
|
url: https://carbon-components-svelte.onrender.com/components/ContentSwitcher
|
||||||
context-menu:
|
context-menu:
|
||||||
name: Context menu
|
name: Context menu
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -182,7 +144,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ContextMenu
|
url: https://carbon-components-svelte.onrender.com/components/ContextMenu
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
- contextual-navigation
|
- contextual-navigation
|
||||||
|
@ -193,7 +155,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/CopyButton
|
url: https://carbon-components-svelte.onrender.com/components/CopyButton
|
||||||
data-table:
|
data-table:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -202,7 +164,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/DataTable
|
url: https://carbon-components-svelte.onrender.com/components/DataTable
|
||||||
date-picker:
|
date-picker:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -211,15 +173,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/DatePicker
|
url: https://carbon-components-svelte.onrender.com/components/DatePicker
|
||||||
definition-tooltip:
|
|
||||||
status: stable
|
|
||||||
framework: svelte
|
|
||||||
demoLinks:
|
|
||||||
- type: storybook
|
|
||||||
name: Storybook
|
|
||||||
action: link
|
|
||||||
url: https://svelte.carbondesignsystem.com/components/TooltipDefinition
|
|
||||||
dropdown:
|
dropdown:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -228,7 +182,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Dropdown
|
url: https://carbon-components-svelte.onrender.com/components/Dropdown
|
||||||
expandable-tile:
|
expandable-tile:
|
||||||
name: Expandable tile
|
name: Expandable tile
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -240,7 +194,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ExpandableTile
|
url: https://carbon-components-svelte.onrender.com/components/ExpandableTile
|
||||||
tags:
|
tags:
|
||||||
- data-display
|
- data-display
|
||||||
- content-element
|
- content-element
|
||||||
|
@ -252,7 +206,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/FileUploader
|
url: https://carbon-components-svelte.onrender.com/components/FileUploader
|
||||||
fluid-form:
|
fluid-form:
|
||||||
name: Fluid form
|
name: Fluid form
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -264,7 +218,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/FluidForm
|
url: https://carbon-components-svelte.onrender.com/components/FluidForm
|
||||||
tags:
|
tags:
|
||||||
- form
|
- form
|
||||||
form:
|
form:
|
||||||
|
@ -275,7 +229,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Form
|
url: https://carbon-components-svelte.onrender.com/components/Form
|
||||||
grid:
|
grid:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -283,7 +237,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Grid
|
url: https://carbon-components-svelte.onrender.com/components/Grid
|
||||||
image-loader:
|
image-loader:
|
||||||
name: Image loader
|
name: Image loader
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -295,7 +249,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ImageLoader
|
url: https://carbon-components-svelte.onrender.com/components/ImageLoader
|
||||||
tags:
|
tags:
|
||||||
- shell
|
- shell
|
||||||
- media
|
- media
|
||||||
|
@ -308,19 +262,19 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/InlineLoading
|
url: https://carbon-components-svelte.onrender.com/components/InlineLoading
|
||||||
inline-notification:
|
inline-notification:
|
||||||
name: Inline notification
|
name: Inline notification
|
||||||
status: stable
|
status: stable
|
||||||
type: component
|
type: component
|
||||||
platform: web
|
platform: web
|
||||||
framework: svelte
|
framework: svelte
|
||||||
thumbnailPath: './thumbnails/inline-notification.svg'
|
thumbnailPath: './thumbnails/inline-loading.svg'
|
||||||
demoLinks:
|
demoLinks:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/InlineNotification
|
url: https://carbon-components-svelte.onrender.com/components/InlineNotification
|
||||||
tags:
|
tags:
|
||||||
- system-feedback
|
- system-feedback
|
||||||
link:
|
link:
|
||||||
|
@ -331,7 +285,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Link
|
url: https://carbon-components-svelte.onrender.com/components/Link
|
||||||
loading:
|
loading:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -340,7 +294,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Loading
|
url: https://carbon-components-svelte.onrender.com/components/Loading
|
||||||
local-storage:
|
local-storage:
|
||||||
name: Local storage
|
name: Local storage
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -352,7 +306,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/LocalStorage
|
url: https://carbon-components-svelte.onrender.com/components/LocalStorage
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
modal:
|
modal:
|
||||||
|
@ -363,7 +317,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Modal
|
url: https://carbon-components-svelte.onrender.com/components/Modal
|
||||||
multiselect:
|
multiselect:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -372,7 +326,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/MultiSelect
|
url: https://carbon-components-svelte.onrender.com/components/MultiSelect
|
||||||
number-input:
|
number-input:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -381,7 +335,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/NumberInput
|
url: https://carbon-components-svelte.onrender.com/components/NumberInput
|
||||||
ordered-list:
|
ordered-list:
|
||||||
name: Ordered list
|
name: Ordered list
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -393,7 +347,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/OrderedList
|
url: https://carbon-components-svelte.onrender.com/components/OrderedList
|
||||||
tags:
|
tags:
|
||||||
- data-display
|
- data-display
|
||||||
overflow-menu:
|
overflow-menu:
|
||||||
|
@ -407,7 +361,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/OverflowMenu
|
url: https://carbon-components-svelte.onrender.com/components/OverflowMenu
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
pagination:
|
pagination:
|
||||||
|
@ -418,7 +372,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Pagination
|
url: https://carbon-components-svelte.onrender.com/components/Pagination
|
||||||
pagination-nav:
|
pagination-nav:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -426,7 +380,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/PaginationNav
|
url: https://carbon-components-svelte.onrender.com/components/PaginationNav
|
||||||
password-input:
|
password-input:
|
||||||
name: Password input
|
name: Password input
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -438,7 +392,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/PasswordInput
|
url: https://carbon-components-svelte.onrender.com/components/PasswordInput
|
||||||
tags:
|
tags:
|
||||||
- form
|
- form
|
||||||
- contextual-navigation
|
- contextual-navigation
|
||||||
|
@ -449,7 +403,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Popover
|
url: https://carbon-components-svelte.onrender.com/components/Popover
|
||||||
progress-bar:
|
progress-bar:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -458,7 +412,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ProgressBar
|
url: https://carbon-components-svelte.onrender.com/components/ProgressBar
|
||||||
progress-indicator:
|
progress-indicator:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -467,7 +421,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ProgressIndicator
|
url: https://carbon-components-svelte.onrender.com/components/ProgressIndicator
|
||||||
radio-button:
|
radio-button:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -476,7 +430,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/RadioButton
|
url: https://carbon-components-svelte.onrender.com/components/RadioButton
|
||||||
radio-tile:
|
radio-tile:
|
||||||
name: Radio tile
|
name: Radio tile
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -488,7 +442,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/RadioTile
|
url: https://carbon-components-svelte.onrender.com/components/RadioTile
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
recursive-list:
|
recursive-list:
|
||||||
|
@ -502,7 +456,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/RecursiveList
|
url: https://carbon-components-svelte.onrender.com/components/RecursiveList
|
||||||
tags:
|
tags:
|
||||||
- data-display
|
- data-display
|
||||||
search:
|
search:
|
||||||
|
@ -513,7 +467,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Search
|
url: https://carbon-components-svelte.onrender.com/components/Search
|
||||||
select:
|
select:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -522,7 +476,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Select
|
url: https://carbon-components-svelte.onrender.com/components/Select
|
||||||
selectable-tile:
|
selectable-tile:
|
||||||
name: Selectable tile
|
name: Selectable tile
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -534,7 +488,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/SelectableTile
|
url: https://carbon-components-svelte.onrender.com/components/SelectableTile
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
skeleton-placeholder:
|
skeleton-placeholder:
|
||||||
|
@ -548,7 +502,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/SkeletonPlaceholder
|
url: https://carbon-components-svelte.onrender.com/components/SkeletonPlaceholder
|
||||||
tags:
|
tags:
|
||||||
- system-feedback
|
- system-feedback
|
||||||
skeleton-text:
|
skeleton-text:
|
||||||
|
@ -562,7 +516,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/SkeletonText
|
url: https://carbon-components-svelte.onrender.com/components/SkeletonText
|
||||||
tags:
|
tags:
|
||||||
- shell
|
- shell
|
||||||
slider:
|
slider:
|
||||||
|
@ -573,7 +527,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Slider
|
url: https://carbon-components-svelte.onrender.com/components/Slider
|
||||||
structured-list:
|
structured-list:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -582,7 +536,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/StructuredList
|
url: https://carbon-components-svelte.onrender.com/components/StructuredList
|
||||||
tabs:
|
tabs:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -591,7 +545,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Tabs
|
url: https://carbon-components-svelte.onrender.com/components/Tabs
|
||||||
tag:
|
tag:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -600,7 +554,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Tag
|
url: https://carbon-components-svelte.onrender.com/components/Tag
|
||||||
text-area:
|
text-area:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -608,7 +562,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/TextArea
|
url: https://carbon-components-svelte.onrender.com/components/TextArea
|
||||||
text-input:
|
text-input:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -617,7 +571,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/TextInput
|
url: https://carbon-components-svelte.onrender.com/components/TextInput
|
||||||
theme:
|
theme:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -625,7 +579,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Theme
|
url: https://carbon-components-svelte.onrender.com/components/Theme
|
||||||
tile:
|
tile:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -634,7 +588,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Tile
|
url: https://carbon-components-svelte.onrender.com/components/Tile
|
||||||
time-picker:
|
time-picker:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -642,7 +596,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/TimePicker
|
url: https://carbon-components-svelte.onrender.com/components/TimePicker
|
||||||
toast-notification:
|
toast-notification:
|
||||||
name: Toast notification
|
name: Toast notification
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -654,7 +608,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/ToastNotification
|
url: https://carbon-components-svelte.onrender.com/components/ToastNotification
|
||||||
tags:
|
tags:
|
||||||
- input-control
|
- input-control
|
||||||
toggle:
|
toggle:
|
||||||
|
@ -665,7 +619,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Toggle
|
url: https://carbon-components-svelte.onrender.com/components/Toggle
|
||||||
tooltip:
|
tooltip:
|
||||||
status: stable
|
status: stable
|
||||||
framework: svelte
|
framework: svelte
|
||||||
|
@ -674,7 +628,15 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Tooltip
|
url: https://carbon-components-svelte.onrender.com/components/Tooltip
|
||||||
|
tooltip-definition:
|
||||||
|
status: stable
|
||||||
|
framework: svelte
|
||||||
|
demoLinks:
|
||||||
|
- type: storybook
|
||||||
|
name: Storybook
|
||||||
|
action: link
|
||||||
|
url: https://carbon-components-svelte.onrender.com/components/TooltipDefinition
|
||||||
tooltip-icon:
|
tooltip-icon:
|
||||||
name: Tootlip icon
|
name: Tootlip icon
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -686,7 +648,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/TooltipIcon
|
url: https://carbon-components-svelte.onrender.com/components/TooltipIcon
|
||||||
tags:
|
tags:
|
||||||
- content-element
|
- content-element
|
||||||
tree-view:
|
tree-view:
|
||||||
|
@ -696,7 +658,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/TreeView
|
url: https://carbon-components-svelte.onrender.com/components/TreeView
|
||||||
truncate:
|
truncate:
|
||||||
name: Truncate
|
name: Truncate
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -708,7 +670,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/Truncate
|
url: https://carbon-components-svelte.onrender.com/components/Truncate
|
||||||
tags:
|
tags:
|
||||||
- data-display
|
- data-display
|
||||||
ui-shell-header:
|
ui-shell-header:
|
||||||
|
@ -719,7 +681,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/UIShell
|
url: https://carbon-components-svelte.onrender.com/components/UIShell
|
||||||
unordered-list:
|
unordered-list:
|
||||||
name: Unordered list
|
name: Unordered list
|
||||||
status: stable
|
status: stable
|
||||||
|
@ -731,7 +693,7 @@ assets:
|
||||||
- type: storybook
|
- type: storybook
|
||||||
name: Storybook
|
name: Storybook
|
||||||
action: link
|
action: link
|
||||||
url: https://svelte.carbondesignsystem.com/components/UnorderedList
|
url: https://carbon-components-svelte.onrender.com/components/UnorderedList
|
||||||
tags:
|
tags:
|
||||||
- data-display
|
- data-display
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
1
docs/.gitignore
vendored
1
docs/.gitignore
vendored
|
@ -1,4 +1,3 @@
|
||||||
/node_modules
|
/node_modules
|
||||||
/dist
|
/dist
|
||||||
/.routify
|
/.routify
|
||||||
src/SEARCH_INDEX.json
|
|
|
@ -3,23 +3,8 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="/favicon.ico" />
|
<link rel="icon" href="/favicon.ico" />
|
||||||
<link rel="canonical" href="https://svelte.carbondesignsystem.com/" />
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="description" content="Svelte implementation of the Carbon Design System" />
|
|
||||||
<title>Carbon Components Svelte</title>
|
<title>Carbon Components Svelte</title>
|
||||||
<script>
|
|
||||||
try {
|
|
||||||
const theme = localStorage.getItem("theme");
|
|
||||||
|
|
||||||
if (["white", "g10", "g80", "g90", "g100"].includes(theme)) {
|
|
||||||
document.documentElement.setAttribute("theme", theme);
|
|
||||||
document.documentElement.style.setProperty(
|
|
||||||
"color-scheme",
|
|
||||||
["white", "g10"].includes(theme) ? "light" : "dark"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (e) {}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<script type="module" src="/src/index.js"></script>
|
<script type="module" src="/src/index.js"></script>
|
||||||
|
|
4002
docs/package-lock.json
generated
4002
docs/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,31 +1,29 @@
|
||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "npm run build:index-docs && run-p dev:*",
|
"dev": "run-p dev:*",
|
||||||
"dev:routify": "cross-env NODE_ENV=development routify run",
|
"dev:routify": "cross-env NODE_ENV=development routify run",
|
||||||
"dev:svite": "vite dev",
|
"dev:svite": "vite dev",
|
||||||
"build": "run-s build:*",
|
"build": "run-s build:*",
|
||||||
"build:index-docs": "node scripts/index-docs.js",
|
|
||||||
"build:routify": "routify run -b",
|
"build:routify": "routify run -b",
|
||||||
"build:svite": "vite build"
|
"build:svite": "vite build"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sveltech/routify": "^1.9.10",
|
"@sveltech/routify": "^1.9.10",
|
||||||
"@sveltejs/vite-plugin-svelte": "^3.1.2",
|
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.40",
|
||||||
"carbon-components-svelte": "file:..",
|
"carbon-components-svelte": "../",
|
||||||
"carbon-icons-svelte": "^13.3.0",
|
"carbon-icons-svelte": "^11.0.1",
|
||||||
"clipboard-copy": "^4.0.1",
|
"clipboard-copy": "^4.0.1",
|
||||||
"cross-env": "^7.0.3",
|
"cross-env": "^7.0.3",
|
||||||
"mdsvex": "^0.12.3",
|
"mdsvex": "^0.9.8",
|
||||||
"minisearch": "^7.1.0",
|
|
||||||
"npm-run-all": "^4.1.5",
|
"npm-run-all": "^4.1.5",
|
||||||
"prettier": "^2.8.8",
|
"prettier": "^2.6.2",
|
||||||
"prettier-plugin-svelte": "^2.10.1",
|
"prettier-plugin-svelte": "^2.6.0",
|
||||||
"prism-svelte": "^0.5.0",
|
"prism-svelte": "^0.4.7",
|
||||||
"prismjs": "^1.30.0",
|
"prismjs": "^1.27.0",
|
||||||
"remark-slug": "^6.1.0",
|
"remark-slug": "^6.0.0",
|
||||||
"svelte": "^4.2.19",
|
"svelte": "^3.46.6",
|
||||||
"vite": "^5.4.20"
|
"vite": "^2.9.1"
|
||||||
},
|
},
|
||||||
"routify": {
|
"routify": {
|
||||||
"routifyDir": ".routify",
|
"routifyDir": ".routify",
|
||||||
|
@ -34,6 +32,5 @@
|
||||||
"svelte",
|
"svelte",
|
||||||
"svx"
|
"svx"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"type": "module"
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,45 +0,0 @@
|
||||||
// @ts-check
|
|
||||||
import fs from "node:fs";
|
|
||||||
import path from "node:path";
|
|
||||||
import githubSlugger from "github-slugger";
|
|
||||||
|
|
||||||
const { slug } = githubSlugger;
|
|
||||||
|
|
||||||
const COMPONENTS_PATH = "./src/pages/components";
|
|
||||||
const SEARCH_INDEX_PATH = "./src/SEARCH_INDEX.json";
|
|
||||||
const H2_DELMIMITER = "## ";
|
|
||||||
|
|
||||||
const files = fs.readdirSync(COMPONENTS_PATH);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @typedef {Object} Document
|
|
||||||
* @property {string} id
|
|
||||||
* @property {string} text
|
|
||||||
* @property {string} description
|
|
||||||
* @property {string} href
|
|
||||||
*/
|
|
||||||
|
|
||||||
/** @type {Document[]} */
|
|
||||||
const documents = [];
|
|
||||||
|
|
||||||
for (const file of files) {
|
|
||||||
const [component_name] = file.split(".");
|
|
||||||
const file_path = path.join(COMPONENTS_PATH, file);
|
|
||||||
const file_content = fs.readFileSync(file_path, "utf8");
|
|
||||||
|
|
||||||
file_content.split("\n").forEach((line) => {
|
|
||||||
if (line.startsWith(H2_DELMIMITER)) {
|
|
||||||
const [, h2] = line.split(H2_DELMIMITER);
|
|
||||||
const hash = slug(h2);
|
|
||||||
|
|
||||||
documents.push({
|
|
||||||
id: component_name + hash,
|
|
||||||
text: component_name,
|
|
||||||
description: h2,
|
|
||||||
href: `/components/${component_name}#${hash}`,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
fs.writeFileSync(SEARCH_INDEX_PATH, JSON.stringify(documents, null, 2));
|
|
|
@ -3,4 +3,4 @@
|
||||||
import { routes } from "../.routify/routes";
|
import { routes } from "../.routify/routes";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<Router {routes} />
|
<Router routes="{routes}" />
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -7,7 +7,6 @@
|
||||||
typedefs: [],
|
typedefs: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
import { onMount } from "svelte";
|
|
||||||
import {
|
import {
|
||||||
OutboundLink,
|
OutboundLink,
|
||||||
StructuredList,
|
StructuredList,
|
||||||
|
@ -18,16 +17,10 @@
|
||||||
UnorderedList,
|
UnorderedList,
|
||||||
ListItem,
|
ListItem,
|
||||||
Tag,
|
Tag,
|
||||||
|
CodeSnippet,
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
import InlineSnippet from "./InlineSnippet.svelte";
|
import InlineSnippet from "./InlineSnippet.svelte";
|
||||||
|
|
||||||
let AsyncPreviewTypeScript;
|
|
||||||
|
|
||||||
onMount(async () => {
|
|
||||||
AsyncPreviewTypeScript = (await import("./PreviewTypeScript.svelte"))
|
|
||||||
.default;
|
|
||||||
});
|
|
||||||
|
|
||||||
const mdn_api = "https://developer.mozilla.org/en-US/docs/Web/API/";
|
const mdn_api = "https://developer.mozilla.org/en-US/docs/Web/API/";
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
string: "string",
|
string: "string",
|
||||||
|
@ -39,21 +32,21 @@
|
||||||
|
|
||||||
$: source = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/${component.filePath}`;
|
$: source = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/${component.filePath}`;
|
||||||
$: forwarded_events = component.events.filter(
|
$: forwarded_events = component.events.filter(
|
||||||
(event) => event.type === "forwarded",
|
(event) => event.type === "forwarded"
|
||||||
);
|
);
|
||||||
$: dispatched_events = component.events.filter(
|
$: dispatched_events = component.events.filter(
|
||||||
(event) => event.type === "dispatched",
|
(event) => event.type === "dispatched"
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<p style="margin-bottom: var(--cds-layout-02)">
|
<p style="margin-bottom: var(--cds-layout-02)">
|
||||||
Source code:
|
Source code:
|
||||||
<OutboundLink size="lg" inline href={source}>
|
<OutboundLink size="lg" inline href="{source}">
|
||||||
{component.filePath}
|
{component.filePath}
|
||||||
</OutboundLink>
|
</OutboundLink>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<h2 id="props">Props</h2>
|
<h3 id="props">Props</h3>
|
||||||
|
|
||||||
{#if component.props.length > 0}
|
{#if component.props.length > 0}
|
||||||
<div class="overflow">
|
<div class="overflow">
|
||||||
|
@ -62,40 +55,26 @@
|
||||||
<StructuredListRow head>
|
<StructuredListRow head>
|
||||||
<StructuredListCell head>Prop name</StructuredListCell>
|
<StructuredListCell head>Prop name</StructuredListCell>
|
||||||
<StructuredListCell head>Type</StructuredListCell>
|
<StructuredListCell head>Type</StructuredListCell>
|
||||||
|
<StructuredListCell head noWrap>Default value</StructuredListCell>
|
||||||
<StructuredListCell head>Description</StructuredListCell>
|
<StructuredListCell head>Description</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
</StructuredListHead>
|
</StructuredListHead>
|
||||||
<StructuredListBody>
|
<StructuredListBody>
|
||||||
{#each component.props.sort((a, b) => {
|
{#each component.props.sort((a, b) => {
|
||||||
// Sort props so required props are listed first, then reactive props.
|
if (a.reactive > b.reactive) return -1;
|
||||||
|
|
||||||
if (a.isRequired !== b.isRequired) {
|
|
||||||
return b.isRequired ? 1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (a.reactive !== b.reactive) {
|
|
||||||
return b.reactive ? 1 : -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}) as prop (prop.name)}
|
}) as prop (prop.name)}
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
<StructuredListCell noWrap>
|
<StructuredListCell noWrap>
|
||||||
<InlineSnippet code={prop.name} />
|
<InlineSnippet code="{prop.name}" />
|
||||||
{#if prop.reactive}
|
{#if prop.reactive}
|
||||||
<div
|
<div
|
||||||
style="white-space: nowrap; margin-top: var(--cds-spacing-03); margin-bottom: var(--cds-spacing-{prop.isRequired
|
style="white-space: nowrap; margin-top: var(--cds-spacing-03); margin-bottom: var(--cds-spacing-03)"
|
||||||
? '01'
|
|
||||||
: '03'})"
|
|
||||||
>
|
>
|
||||||
<Tag style="margin-left: 0" size="sm" type="cyan">
|
<Tag style="margin-left: 0" size="sm" type="cyan">
|
||||||
Reactive
|
Reactive
|
||||||
</Tag>
|
</Tag>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
{#if prop.isRequired}
|
|
||||||
<Tag size="sm" type="magenta">Required</Tag>
|
|
||||||
{/if}
|
|
||||||
</StructuredListCell>
|
</StructuredListCell>
|
||||||
<StructuredListCell>
|
<StructuredListCell>
|
||||||
{#each (prop.type || "").split(" | ") as type, i (type)}
|
{#each (prop.type || "").split(" | ") as type, i (type)}
|
||||||
|
@ -111,29 +90,16 @@
|
||||||
{type}
|
{type}
|
||||||
</OutboundLink>
|
</OutboundLink>
|
||||||
{:else if type in typeMap}
|
{:else if type in typeMap}
|
||||||
<div
|
<code>{typeMap[type]}</code>
|
||||||
style="display: inline-flex; max-width: 220px; word-break: break-word;"
|
{:else if type.startsWith("(")}
|
||||||
>
|
<code>{type}</code>
|
||||||
<svelte:component
|
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
type="inline"
|
|
||||||
code={typeMap[type]}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{:else}
|
{:else}
|
||||||
<div
|
<InlineSnippet code="{type}" />
|
||||||
style="display: inline-flex; max-width: 220px; word-break: break-word;"
|
|
||||||
>
|
|
||||||
<svelte:component
|
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
type="inline"
|
|
||||||
code={type}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</StructuredListCell>
|
</StructuredListCell>
|
||||||
|
<StructuredListCell><code>{prop.value}</code></StructuredListCell>
|
||||||
<StructuredListCell>
|
<StructuredListCell>
|
||||||
{#if prop.description}
|
{#if prop.description}
|
||||||
{#each prop.description.split("\n") as line}
|
{#each prop.description.split("\n") as line}
|
||||||
|
@ -144,27 +110,9 @@
|
||||||
.replace(/`(.*?)`/g, "<code>$1</code>")}.
|
.replace(/`(.*?)`/g, "<code>$1</code>")}.
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
|
{:else}
|
||||||
|
<div class="description">No description available.</div>
|
||||||
{/if}
|
{/if}
|
||||||
<div
|
|
||||||
style:margin-top="var(--cds-layout-02)"
|
|
||||||
style:margin-bottom="var(--cds-spacing-03)"
|
|
||||||
>
|
|
||||||
<strong>Default value</strong>
|
|
||||||
</div>
|
|
||||||
<div
|
|
||||||
style:margin-bottom="var(--cds-layout-01)"
|
|
||||||
style:max-width="85%"
|
|
||||||
>
|
|
||||||
{#if prop.value === undefined}
|
|
||||||
<em>undefined</em>
|
|
||||||
{:else}
|
|
||||||
<svelte:component
|
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
type={/\n/.test(prop.value) ? "multi" : "inline"}
|
|
||||||
code={prop.value}
|
|
||||||
/>
|
|
||||||
{/if}
|
|
||||||
</div>
|
|
||||||
</StructuredListCell>
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
{/each}
|
{/each}
|
||||||
|
@ -175,50 +123,31 @@
|
||||||
<p class="my-layout-01-03">No props.</p>
|
<p class="my-layout-01-03">No props.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="typedefs">Typedefs</h2>
|
<h3 id="typedefs">Typedefs</h3>
|
||||||
|
|
||||||
{#if component.typedefs.length > 0}
|
{#if component.typedefs.length > 0}
|
||||||
<div class="my-layout-01-03">
|
<CodeSnippet
|
||||||
<svelte:component
|
style="margin-top: var(--cds-spacing-08)"
|
||||||
this={AsyncPreviewTypeScript}
|
class="my-layout-01-03"
|
||||||
code={component.typedefs.map((t) => t.ts).join("\n")}
|
type="multi"
|
||||||
/>
|
code="{component.typedefs.map((t) => t.ts).join(';\n\n')};"
|
||||||
</div>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<p class="my-layout-01-03">No typedefs.</p>
|
<p class="my-layout-01-03">No typedefs.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="slots">Slots</h2>
|
<h3 id="slots">Slots</h3>
|
||||||
{#if component.slots.length > 0}
|
{#if component.slots.length > 0}
|
||||||
<StructuredList class="my-layout-01-03">
|
<UnorderedList class="my-layout-01-03">
|
||||||
<StructuredListHead>
|
{#each component.slots as slot (slot.name)}
|
||||||
<StructuredListRow>
|
<ListItem>{slot.default ? "default" : slot.name}</ListItem>
|
||||||
<StructuredListCell>Slot name</StructuredListCell>
|
{/each}
|
||||||
<StructuredListCell>Slot detail</StructuredListCell>
|
</UnorderedList>
|
||||||
</StructuredListRow>
|
|
||||||
</StructuredListHead>
|
|
||||||
<StructuredListBody>
|
|
||||||
{#each component.slots as slot (slot.name)}
|
|
||||||
<StructuredListRow>
|
|
||||||
<StructuredListCell>
|
|
||||||
<strong>{slot.default ? "default" : slot.name}</strong>
|
|
||||||
</StructuredListCell>
|
|
||||||
<StructuredListCell>
|
|
||||||
<svelte:component
|
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
type={/\n/.test(slot.slot_props) ? "multi" : "inline"}
|
|
||||||
code={slot.slot_props}
|
|
||||||
/>
|
|
||||||
</StructuredListCell>
|
|
||||||
</StructuredListRow>
|
|
||||||
{/each}
|
|
||||||
</StructuredListBody>
|
|
||||||
</StructuredList>
|
|
||||||
{:else}
|
{:else}
|
||||||
<p class="my-layout-01-03">No slots.</p>
|
<p class="my-layout-01-03">No slots.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="forwarded-events">Forwarded events</h2>
|
<h3 id="forwarded-events">Forwarded events</h3>
|
||||||
{#if forwarded_events.length > 0}
|
{#if forwarded_events.length > 0}
|
||||||
<UnorderedList class="my-layout-01-03">
|
<UnorderedList class="my-layout-01-03">
|
||||||
{#each forwarded_events as event (event.name)}
|
{#each forwarded_events as event (event.name)}
|
||||||
|
@ -229,45 +158,19 @@
|
||||||
<p class="my-layout-01-03">No forwarded events.</p>
|
<p class="my-layout-01-03">No forwarded events.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="dispatched-events">Dispatched events</h2>
|
<h3 id="dispatched-events">Dispatched events</h3>
|
||||||
|
|
||||||
{#if dispatched_events.length > 0}
|
{#if dispatched_events.length > 0}
|
||||||
{@const hasDescription = dispatched_events.find((el) => el.description)}
|
<UnorderedList class="my-layout-01-03">
|
||||||
<StructuredList flush>
|
{#each dispatched_events as event (event.name)}
|
||||||
<StructuredListHead>
|
<ListItem>on:{event.name}</ListItem>
|
||||||
<StructuredListRow>
|
{/each}
|
||||||
<StructuredListCell>Event name</StructuredListCell>
|
</UnorderedList>
|
||||||
<StructuredListCell>Event detail</StructuredListCell>
|
|
||||||
{#if hasDescription}
|
|
||||||
<StructuredListCell>Description</StructuredListCell>
|
|
||||||
{/if}
|
|
||||||
</StructuredListRow>
|
|
||||||
</StructuredListHead>
|
|
||||||
<StructuredListBody>
|
|
||||||
{#each dispatched_events as event (event.name)}
|
|
||||||
<StructuredListRow>
|
|
||||||
<StructuredListCell>
|
|
||||||
<strong>on:{event.name}</strong>
|
|
||||||
</StructuredListCell>
|
|
||||||
<StructuredListCell>
|
|
||||||
<svelte:component
|
|
||||||
this={AsyncPreviewTypeScript}
|
|
||||||
type={/\n/.test(event.detail) ? "multi" : "inline"}
|
|
||||||
code={event.detail}
|
|
||||||
/>
|
|
||||||
</StructuredListCell>
|
|
||||||
<StructuredListCell>
|
|
||||||
{event.description ?? ""}
|
|
||||||
</StructuredListCell>
|
|
||||||
</StructuredListRow>
|
|
||||||
{/each}
|
|
||||||
</StructuredListBody>
|
|
||||||
</StructuredList>
|
|
||||||
{:else}
|
{:else}
|
||||||
<p class="my-layout-01-03">No dispatched events.</p>
|
<p class="my-layout-01-03">No dispatched events.</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<h2 id="rest-props">$$restProps</h2>
|
<h3 id="rest-props">$$restProps</h3>
|
||||||
|
|
||||||
<div class="my-layout-01-03">
|
<div class="my-layout-01-03">
|
||||||
{#if component.rest_props}
|
{#if component.rest_props}
|
||||||
|
@ -285,7 +188,6 @@
|
||||||
<style>
|
<style>
|
||||||
.description {
|
.description {
|
||||||
margin-bottom: var(--cds-spacing-04);
|
margin-bottom: var(--cds-spacing-04);
|
||||||
width: 80%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.cell {
|
.cell {
|
||||||
|
@ -299,11 +201,7 @@
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.my-layout-01-03) {
|
:global(.my-layout-01-03),
|
||||||
margin-top: var(--cds-layout-01);
|
|
||||||
margin-bottom: var(--cds-layout-03);
|
|
||||||
}
|
|
||||||
|
|
||||||
:global(.overflow .bx--structured-list) {
|
:global(.overflow .bx--structured-list) {
|
||||||
margin-top: var(--cds-layout-01);
|
margin-top: var(--cds-layout-01);
|
||||||
margin-bottom: var(--cds-layout-04);
|
margin-bottom: var(--cds-layout-04);
|
||||||
|
@ -313,11 +211,7 @@
|
||||||
word-break: break-word;
|
word-break: break-word;
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(
|
:global(.cell .bx--snippet--inline code, .bx--snippet--single pre) {
|
||||||
.cell .bx--snippet--inline code,
|
|
||||||
.cell .bx--snippet--single pre,
|
|
||||||
.bx--snippet--inline code
|
|
||||||
) {
|
|
||||||
white-space: pre-wrap !important;
|
white-space: pre-wrap !important;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<CodeSnippet {code} type="inline" copy={(text) => copy(text)} />
|
<CodeSnippet code="{code}" type="inline" copy="{(text) => copy(text)}" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
|
@ -26,8 +26,8 @@
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
size="field"
|
size="field"
|
||||||
href={themedSrcUrl}
|
href="{themedSrcUrl}"
|
||||||
icon={Launch}
|
icon="{Launch}"
|
||||||
>
|
>
|
||||||
Open in new tab
|
Open in new tab
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -35,14 +35,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
<div class="preview-viewer" class:framed>
|
<div class="preview-viewer" class:framed>
|
||||||
{#if framed}
|
{#if framed}
|
||||||
<iframe loading="lazy" title={src.split("/").pop()} src={themedSrcUrl}
|
<iframe title="{src.split('/').pop()}" src="{themedSrcUrl}"></iframe>
|
||||||
></iframe>
|
|
||||||
{:else}
|
{:else}
|
||||||
<slot />
|
<slot />
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
<div class="code-override">
|
<div class="code-override">
|
||||||
<CodeSnippet type="multi" code={codeRaw} copy={(text) => copy(text)}>
|
<CodeSnippet type="multi" code="{codeRaw}" copy="{(text) => copy(text)}">
|
||||||
{@html code}
|
{@html code}
|
||||||
</CodeSnippet>
|
</CodeSnippet>
|
||||||
</div>
|
</div>
|
||||||
|
@ -53,7 +52,7 @@
|
||||||
margin-bottom: var(--cds-layout-04);
|
margin-bottom: var(--cds-layout-04);
|
||||||
margin-left: -1rem;
|
margin-left: -1rem;
|
||||||
margin-right: -1rem;
|
margin-right: -1rem;
|
||||||
max-width: 80rem;
|
max-width: 56rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-override {
|
.code-override {
|
||||||
|
@ -75,12 +74,6 @@
|
||||||
min-height: 20rem;
|
min-height: 20rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media (min-width: 1920px) {
|
|
||||||
.preview-viewer.framed {
|
|
||||||
min-height: 32rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.framed-header {
|
.framed-header {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
@ -1,29 +0,0 @@
|
||||||
<script>
|
|
||||||
export let code = "";
|
|
||||||
export let type = "multi";
|
|
||||||
|
|
||||||
import { CodeSnippet } from "carbon-components-svelte";
|
|
||||||
import { highlight } from "prismjs";
|
|
||||||
import "prismjs/components/prism-typescript";
|
|
||||||
import copy from "clipboard-copy";
|
|
||||||
|
|
||||||
$: highlightedCode = highlight(
|
|
||||||
code,
|
|
||||||
Prism.languages.typescript,
|
|
||||||
"typescript",
|
|
||||||
);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
{#if type === "multi"}
|
|
||||||
<div class="code-override">
|
|
||||||
<CodeSnippet type="multi" {code} {copy}>
|
|
||||||
{@html highlightedCode}
|
|
||||||
</CodeSnippet>
|
|
||||||
</div>
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
{#if type === "inline"}
|
|
||||||
<CodeSnippet type="inline" class="code-override-inline" {code} {copy}>
|
|
||||||
{@html highlightedCode}
|
|
||||||
</CodeSnippet>
|
|
||||||
{/if}
|
|
30
docs/src/components/Theme.svelte
Normal file
30
docs/src/components/Theme.svelte
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<script>
|
||||||
|
export let persist = false;
|
||||||
|
export let persistKey = "carbon-theme";
|
||||||
|
export const themes = ["white", "g10", "g80", "g90", "g100"];
|
||||||
|
|
||||||
|
import { onMount, afterUpdate } from "svelte";
|
||||||
|
import { theme } from "../store";
|
||||||
|
|
||||||
|
const isValidTheme = (value) => themes.includes(value);
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
try {
|
||||||
|
const persisted_theme = localStorage.getItem(persistKey);
|
||||||
|
if (isValidTheme(persisted_theme)) theme.set(persisted_theme);
|
||||||
|
} catch (e) {}
|
||||||
|
});
|
||||||
|
|
||||||
|
afterUpdate(() => {
|
||||||
|
if (isValidTheme($theme)) {
|
||||||
|
document.documentElement.setAttribute("theme", $theme);
|
||||||
|
if (persist) {
|
||||||
|
try {
|
||||||
|
localStorage.setItem(persistKey, $theme);
|
||||||
|
} catch (e) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<slot />
|
|
@ -15,8 +15,8 @@
|
||||||
<div class="card-wrapper" class:borderRight class:borderBottom>
|
<div class="card-wrapper" class:borderRight class:borderBottom>
|
||||||
<AspectRatio>
|
<AspectRatio>
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={tileComponent}
|
this="{tileComponent}"
|
||||||
{href}
|
href="{href}"
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
style="height: 100%;"
|
style="height: 100%;"
|
||||||
>
|
>
|
||||||
|
@ -29,11 +29,11 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<svelte:component
|
<svelte:component
|
||||||
this={LogoGithub}
|
this="{LogoGithub}"
|
||||||
size={32}
|
size="{32}"
|
||||||
style="fill: var(--cds-icon-01)"
|
style="fill: var(--cds-icon-01)"
|
||||||
/>
|
/>
|
||||||
<Launch size={20} style="fill: var(--cds-icon-01)" />
|
<Launch size="{20}" style="fill: var(--cds-icon-01)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</svelte:component>
|
</svelte:component>
|
||||||
|
|
|
@ -2,19 +2,10 @@ html[theme="g90"] .code-override {
|
||||||
border: 1px solid var(--cds-ui-03);
|
border: 1px solid var(--cds-ui-03);
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose > pre,
|
|
||||||
.code-override .bx--snippet {
|
.code-override .bx--snippet {
|
||||||
/** Docs code snippet is always dark mode */
|
|
||||||
color-scheme: dark;
|
|
||||||
max-width: none;
|
max-width: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose > pre {
|
|
||||||
padding: 1rem;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.prose > pre,
|
|
||||||
.code-override .bx--copy-btn,
|
.code-override .bx--copy-btn,
|
||||||
.code-override .bx--snippet,
|
.code-override .bx--snippet,
|
||||||
.code-override button.bx--btn.bx--snippet-btn--expand {
|
.code-override button.bx--btn.bx--snippet-btn--expand {
|
||||||
|
@ -31,7 +22,6 @@ html[theme="g90"] .code-override {
|
||||||
fill: #f4f4f4;
|
fill: #f4f4f4;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prose > pre,
|
|
||||||
.code-override .bx--snippet-container pre {
|
.code-override .bx--snippet-container pre {
|
||||||
font-size: var(--cds-code-02-font-size);
|
font-size: var(--cds-code-02-font-size);
|
||||||
line-height: var(--cds-code-02-line-height);
|
line-height: var(--cds-code-02-line-height);
|
||||||
|
@ -43,28 +33,11 @@ html[theme="g90"] .code-override {
|
||||||
overflow-x: auto;
|
overflow-x: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Addig this to the layout grid fixes overstretching. */
|
|
||||||
.fix-overflow {
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.tag,
|
.token.tag,
|
||||||
.token.operator {
|
.token.operator {
|
||||||
color: #6ea6ff;
|
color: #6ea6ff;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Override syntax highlighting for light theme inline code .*/
|
|
||||||
[theme="white"] .code-override-inline .token,
|
|
||||||
[theme="g10"] .code-override-inline .token {
|
|
||||||
color: var(--cds-text-01, #161616);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Gray 80 is the "lighted" dark theme. Ensure the background is dark. */
|
|
||||||
[theme="g80"] .code-override-inline {
|
|
||||||
background-color: #262626;
|
|
||||||
}
|
|
||||||
|
|
||||||
.token.builtin,
|
|
||||||
.token.attr-name {
|
.token.attr-name {
|
||||||
color: #3ddbd9; /* teal 30 */
|
color: #3ddbd9; /* teal 30 */
|
||||||
}
|
}
|
||||||
|
@ -116,24 +89,6 @@ html[theme="g90"] .code-override {
|
||||||
width: auto;
|
width: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Main content needs to supersede z-index of SideNav but not that of the Header.
|
|
||||||
* UI Shell Header shares the same z-index.
|
|
||||||
*/
|
|
||||||
[aria-label="Navigation"] {
|
|
||||||
z-index: calc(8000 + 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
[aria-label="Navigation"] ~ [data-components] {
|
|
||||||
z-index: calc(8000 + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (max-width: 65.98rem) {
|
|
||||||
[aria-label="Navigation"] ~ [data-components] {
|
|
||||||
z-index: 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.prose > p > .bx--link {
|
.prose > p > .bx--link {
|
||||||
font-size: inherit;
|
font-size: inherit;
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
|
@ -147,7 +102,6 @@ html[theme="g90"] .code-override {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
max-height: calc(100vh - 3rem);
|
max-height: calc(100vh - 3rem);
|
||||||
top: 3rem;
|
top: 3rem;
|
||||||
margin-top: -3rem;
|
|
||||||
padding-top: var(--cds-spacing-05);
|
padding-top: var(--cds-spacing-05);
|
||||||
padding-bottom: var(--cds-spacing-05);
|
padding-bottom: var(--cds-spacing-05);
|
||||||
padding-left: var(--cds-spacing-08);
|
padding-left: var(--cds-spacing-08);
|
||||||
|
@ -155,6 +109,7 @@ html[theme="g90"] .code-override {
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-components] {
|
[data-components] {
|
||||||
|
z-index: 2;
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
@ -194,11 +149,18 @@ html[theme="g90"] .code-override {
|
||||||
margin-bottom: var(--cds-layout-01);
|
margin-bottom: var(--cds-layout-01);
|
||||||
}
|
}
|
||||||
|
|
||||||
.code-01 {
|
.table {
|
||||||
font-size: var(--cds-code-01-font-size);
|
position: sticky;
|
||||||
font-weight: var(--cds-code-01-font-weight);
|
max-height: calc(100vh - 3rem);
|
||||||
letter-spacing: var(--cds-code-01-letter-spacing);
|
top: 3rem;
|
||||||
line-height: var(--cds-code-01-line-height);
|
padding-top: var(--cds-spacing-05);
|
||||||
|
padding-bottom: var(--cds-spacing-05);
|
||||||
|
padding-left: var(--cds-spacing-08);
|
||||||
|
overflow-y: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx--side-nav__overlay-active {
|
||||||
|
z-index: calc(10 + 1); /** supersede the z-index of code snippets */
|
||||||
}
|
}
|
||||||
|
|
||||||
.body-short-01 {
|
.body-short-01 {
|
||||||
|
@ -209,10 +171,10 @@ html[theme="g90"] .code-override {
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx--col > h1 {
|
.bx--col > h1 {
|
||||||
font-size: var(--cds-expressive-heading-05-font-size);
|
font-size: var(--cds-display-01-font-size);
|
||||||
font-weight: var(--cds-expressive-heading-05-font-weight);
|
font-weight: var(--cds-display-01-font-weight);
|
||||||
letter-spacing: var(--cds-expressive-heading-05-letter-spacing);
|
letter-spacing: var(--cds-display-01-letter-spacing);
|
||||||
line-height: var(--cds-expressive-heading-05-line-height);
|
line-height: var(--cds-display-01-line-height);
|
||||||
margin-bottom: var(--cds-layout-01);
|
margin-bottom: var(--cds-layout-01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,13 +209,21 @@ html[theme="g90"] .code-override {
|
||||||
padding: 0 var(--cds-spacing-02);
|
padding: 0 var(--cds-spacing-02);
|
||||||
}
|
}
|
||||||
|
|
||||||
[class*="bx--col"] > h2,
|
.bx--col > h2 {
|
||||||
.bx--tab-content > h2 {
|
font-size: var(--cds-expressive-heading-05-font-size);
|
||||||
|
font-weight: var(--cds-expressive-heading-05-font-weight);
|
||||||
|
letter-spacing: var(--cds-expressive-heading-05-letter-spacing);
|
||||||
|
line-height: var(--cds-expressive-heading-05-line-height);
|
||||||
|
padding-top: var(--cds-layout-04);
|
||||||
|
margin-bottom: var(--cds-layout-01);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx--col > h3 {
|
||||||
font-size: var(--cds-expressive-heading-04-font-size);
|
font-size: var(--cds-expressive-heading-04-font-size);
|
||||||
font-weight: var(--cds-expressive-heading-04-font-weight);
|
font-weight: var(--cds-expressive-heading-04-font-weight);
|
||||||
letter-spacing: var(--cds-expressive-heading-04-letter-spacing);
|
letter-spacing: var(--cds-expressive-heading-04-letter-spacing);
|
||||||
line-height: var(--cds-expressive-heading-04-line-height);
|
line-height: var(--cds-expressive-heading-04-line-height);
|
||||||
padding-top: var(--cds-layout-03);
|
padding-top: var(--cds-layout-04);
|
||||||
margin-bottom: var(--cds-layout-01);
|
margin-bottom: var(--cds-layout-01);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,13 +236,33 @@ html[theme="g90"] .code-override {
|
||||||
margin-bottom: var(--cds-layout-01);
|
margin-bottom: var(--cds-layout-01);
|
||||||
}
|
}
|
||||||
|
|
||||||
.bx--col > h2,
|
|
||||||
.bx--tab-content > h2,
|
|
||||||
.bx--col > h3,
|
|
||||||
.bx--col > h4 {
|
|
||||||
scroll-margin-top: 3rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.bx--col > p {
|
.bx--col > p {
|
||||||
margin-bottom: var(--cds-layout-02);
|
margin-bottom: var(--cds-layout-02);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main.bx--content {
|
||||||
|
min-height: calc(100vh - 3rem - 3rem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1056px) {
|
||||||
|
.bx--side-nav ~ .bx--content {
|
||||||
|
margin-left: 0;
|
||||||
|
padding-left: 1rem;
|
||||||
|
padding-right: 1rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx--side-nav--expanded ~ .bx--content {
|
||||||
|
white-space: nowrap;
|
||||||
|
min-width: 28rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (min-width: 1057px) {
|
||||||
|
.bx--side-nav__navigation {
|
||||||
|
z-index: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.bx--side-nav__submenu[aria-expanded="true"] + .bx--side-nav__menu {
|
||||||
|
max-height: 144rem;
|
||||||
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
export let component = $page.title;
|
export let component = $page.title;
|
||||||
export let components = [component];
|
export let components = [component];
|
||||||
|
export let source = "";
|
||||||
export let unreleased = false;
|
export let unreleased = false;
|
||||||
export let unstable = false;
|
export let unstable = false;
|
||||||
|
|
||||||
|
@ -29,52 +30,26 @@
|
||||||
|
|
||||||
// TODO: `find` is not supported in IE
|
// TODO: `find` is not supported in IE
|
||||||
$: api_components = components.map((i) =>
|
$: api_components = components.map((i) =>
|
||||||
COMPONENT_API.components.find((_) => _.moduleName === i),
|
COMPONENT_API.components.find((_) => _.moduleName === i)
|
||||||
);
|
);
|
||||||
$: multiple = api_components.length > 1;
|
$: multiple = api_components.length > 1;
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
const searchParams = new URLSearchParams(window.location.search);
|
const currentTheme = window.location.search.split("?theme=")[1];
|
||||||
const current_theme = searchParams.get("theme");
|
|
||||||
|
|
||||||
if (["white", "g10", "g80", "g90", "g100"].includes(current_theme)) {
|
if (["white", "g10", "g80", "g90", "g100"].includes(currentTheme)) {
|
||||||
theme.set(current_theme);
|
theme.set(currentTheme);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
function formatSourceURL(multiple) {
|
|
||||||
const filePath = api_components[0]?.filePath ?? "";
|
|
||||||
|
|
||||||
if (multiple) {
|
|
||||||
/**
|
|
||||||
* Link to folder for doc with multiple components.
|
|
||||||
* @example "src/Breadcrumb"
|
|
||||||
*/
|
|
||||||
return filePath.split("/").slice(0, -1).join("/");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Else, link to the component source.
|
|
||||||
* @example "src/Tile/ClickableTile.svelte"
|
|
||||||
*/
|
|
||||||
return filePath;
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: [refactor] read from package.json value
|
// TODO: [refactor] read from package.json value
|
||||||
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/${formatSourceURL(
|
$: sourceCode = `https://github.com/carbon-design-system/carbon-components-svelte/tree/master/src/${
|
||||||
multiple,
|
source || `${$page.title}/${$page.title}.svelte`
|
||||||
)}`;
|
}`;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<link
|
|
||||||
rel="canonical"
|
|
||||||
href="https://svelte.carbondesignsystem.com/components/{component}"
|
|
||||||
/>
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<Content data-components>
|
<Content data-components>
|
||||||
<Grid class="fix-overflow">
|
<Grid>
|
||||||
<Row>
|
<Row>
|
||||||
<Column>
|
<Column>
|
||||||
<h1>{component}</h1>
|
<h1>{component}</h1>
|
||||||
|
@ -83,7 +58,7 @@
|
||||||
id="select-theme"
|
id="select-theme"
|
||||||
inline
|
inline
|
||||||
labelText="Theme"
|
labelText="Theme"
|
||||||
bind:selected={$theme}
|
bind:selected="{$theme}"
|
||||||
>
|
>
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
|
@ -95,8 +70,8 @@
|
||||||
kind="ghost"
|
kind="ghost"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
size="field"
|
size="field"
|
||||||
href={sourceCode}
|
href="{sourceCode}"
|
||||||
icon={Code}
|
icon="{Code}"
|
||||||
>
|
>
|
||||||
Source code
|
Source code
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -125,9 +100,10 @@
|
||||||
<Row>
|
<Row>
|
||||||
<Column class="prose">
|
<Column class="prose">
|
||||||
<div class="toc mobile">
|
<div class="toc mobile">
|
||||||
<h5>Examples</h5>
|
<h5>Table of Contents</h5>
|
||||||
<slot name="aside" />
|
<slot name="aside" />
|
||||||
</div>
|
</div>
|
||||||
|
<h2 id="usage">Usage</h2>
|
||||||
<slot />
|
<slot />
|
||||||
<h2 id="component-api">Component API</h2>
|
<h2 id="component-api">Component API</h2>
|
||||||
<p>
|
<p>
|
||||||
|
@ -144,30 +120,30 @@
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Column class="prose" noGutter={multiple}>
|
<Column class="prose" noGutter="{multiple}">
|
||||||
{#if multiple}
|
{#if multiple}
|
||||||
<Tabs class="override-tabs">
|
<Tabs class="override-tabs">
|
||||||
{#each api_components as component (component.moduleName)}
|
{#each api_components as component (component.moduleName)}
|
||||||
<Tab label={component.moduleName} />
|
<Tab label="{component.moduleName}" />
|
||||||
{/each}
|
{/each}
|
||||||
<div slot="content" style="padding-top: var(--cds-spacing-06)">
|
<div slot="content" style="padding-top: var(--cds-spacing-06)">
|
||||||
{#each api_components as component (component.moduleName)}
|
{#each api_components as component (component.moduleName)}
|
||||||
<TabContent>
|
<TabContent>
|
||||||
<ComponentApi {component} />
|
<ComponentApi component="{component}" />
|
||||||
</TabContent>
|
</TabContent>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
{:else}
|
{:else}
|
||||||
<ComponentApi component={api_components[0]} />
|
<ComponentApi component="{api_components[0]}" />
|
||||||
{/if}
|
{/if}
|
||||||
</Column>
|
</Column>
|
||||||
</Row>
|
</Row>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
<Column class="table" xlg={4} lg={5}>
|
<Column class="table" xlg="{4}" lg="{5}">
|
||||||
<div class="toc">
|
<div class="toc">
|
||||||
<h5>Examples</h5>
|
<h5>Table of Contents</h5>
|
||||||
<slot name="aside" />
|
<slot name="aside" />
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
|
@ -181,8 +157,7 @@
|
||||||
border-bottom: 1px solid var(--cds-ui-03);
|
border-bottom: 1px solid var(--cds-ui-03);
|
||||||
}
|
}
|
||||||
|
|
||||||
:global(.toc h5) {
|
.toc h5 {
|
||||||
margin-top: var(--cds-spacing-06);
|
|
||||||
margin-bottom: var(--cds-spacing-03);
|
margin-bottom: var(--cds-spacing-03);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +168,6 @@
|
||||||
@media (max-width: 1056px) {
|
@media (max-width: 1056px) {
|
||||||
.toc.mobile {
|
.toc.mobile {
|
||||||
display: block;
|
display: block;
|
||||||
margin-bottom: var(--cds-spacing-09);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
88
docs/src/layouts/Recipe.svelte
Normal file
88
docs/src/layouts/Recipe.svelte
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
<script>
|
||||||
|
import {
|
||||||
|
Grid,
|
||||||
|
Row,
|
||||||
|
Column,
|
||||||
|
Content,
|
||||||
|
Select,
|
||||||
|
SelectItem,
|
||||||
|
} from "carbon-components-svelte";
|
||||||
|
import { page, metatags } from "@sveltech/routify";
|
||||||
|
import { onMount } from "svelte";
|
||||||
|
import { theme } from "../store";
|
||||||
|
|
||||||
|
export let component = $page.title;
|
||||||
|
|
||||||
|
metatags.title = $page.title;
|
||||||
|
|
||||||
|
onMount(() => {
|
||||||
|
const currentTheme = window.location.search.split("?theme=")[1];
|
||||||
|
|
||||||
|
if (["white", "g10", "g90", "g100"].includes(currentTheme)) {
|
||||||
|
theme.set(currentTheme);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Content data-components>
|
||||||
|
<Grid>
|
||||||
|
<Row>
|
||||||
|
<Column>
|
||||||
|
<h1>{component}</h1>
|
||||||
|
<div class="bar">
|
||||||
|
<Select
|
||||||
|
id="select-theme"
|
||||||
|
inline
|
||||||
|
labelText="Theme"
|
||||||
|
bind:selected="{$theme}"
|
||||||
|
>
|
||||||
|
<SelectItem value="white" text="White" />
|
||||||
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
|
<SelectItem value="g90" text="Gray 90" />
|
||||||
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
|
</Select>
|
||||||
|
</div>
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Row>
|
||||||
|
<Column class="prose">
|
||||||
|
<div class="toc mobile">
|
||||||
|
<h5>Table of Contents</h5>
|
||||||
|
<slot name="aside" />
|
||||||
|
</div>
|
||||||
|
<slot />
|
||||||
|
</Column>
|
||||||
|
</Row>
|
||||||
|
</Grid>
|
||||||
|
|
||||||
|
<Column class="table" xlg="{4}" lg="{5}">
|
||||||
|
<div class="toc">
|
||||||
|
<h5>Table of Contents</h5>
|
||||||
|
<slot name="aside" />
|
||||||
|
</div>
|
||||||
|
</Column>
|
||||||
|
</Content>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-bottom: var(--cds-layout-02);
|
||||||
|
border-bottom: 1px solid var(--cds-ui-03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toc h5 {
|
||||||
|
margin-bottom: var(--cds-spacing-03);
|
||||||
|
}
|
||||||
|
|
||||||
|
.toc.mobile {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 1056px) {
|
||||||
|
.toc.mobile {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -12,7 +12,7 @@
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<div>
|
<div>
|
||||||
Page not found.
|
Page not found.
|
||||||
<Link href={$url("/")}>Return home</Link>
|
<Link href="{$url('/')}">Return home</Link>
|
||||||
</div>
|
</div>
|
||||||
</Column>
|
</Column>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { isActive, url, layout, beforeUrlChange } from "@sveltech/routify";
|
||||||
isActive,
|
|
||||||
url,
|
|
||||||
layout,
|
|
||||||
beforeUrlChange,
|
|
||||||
goto,
|
|
||||||
} from "@sveltech/routify";
|
|
||||||
import {
|
import {
|
||||||
Header,
|
Header,
|
||||||
HeaderUtilities,
|
HeaderUtilities,
|
||||||
|
@ -14,46 +8,28 @@
|
||||||
HeaderPanelLinks,
|
HeaderPanelLinks,
|
||||||
HeaderPanelLink,
|
HeaderPanelLink,
|
||||||
HeaderPanelDivider,
|
HeaderPanelDivider,
|
||||||
HeaderSearch,
|
|
||||||
SkipToContent,
|
SkipToContent,
|
||||||
SideNav,
|
SideNav,
|
||||||
SideNavItems,
|
SideNavItems,
|
||||||
|
SideNavMenu,
|
||||||
SideNavMenuItem,
|
SideNavMenuItem,
|
||||||
Theme,
|
|
||||||
Tag,
|
Tag,
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
import MiniSearch from "minisearch";
|
|
||||||
import LogoGithub from "carbon-icons-svelte/lib/LogoGithub.svelte";
|
import LogoGithub from "carbon-icons-svelte/lib/LogoGithub.svelte";
|
||||||
import { theme } from "../store";
|
import Theme from "../components/Theme.svelte";
|
||||||
import SEARCH_INDEX from "../SEARCH_INDEX.json";
|
|
||||||
|
|
||||||
const miniSearch = new MiniSearch({
|
|
||||||
fields: ["text", "description"],
|
|
||||||
storeFields: ["text", "description", "href"],
|
|
||||||
searchOptions: {
|
|
||||||
prefix: true,
|
|
||||||
boost: { description: 2 },
|
|
||||||
fuzzy: 0.1,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
miniSearch.addAll(SEARCH_INDEX);
|
|
||||||
|
|
||||||
const deprecated = [];
|
const deprecated = [];
|
||||||
const new_components = [];
|
const new_components = [];
|
||||||
|
|
||||||
let value = "";
|
|
||||||
let active = false;
|
|
||||||
$: results = miniSearch.search(value).slice(0, 10);
|
|
||||||
|
|
||||||
let isOpen = false;
|
let isOpen = false;
|
||||||
let isSideNavOpen = true;
|
let isSideNavOpen = true;
|
||||||
let innerWidth = 2048;
|
let innerWidth = 2048;
|
||||||
|
|
||||||
$: isMobile = innerWidth < 1056;
|
$: isMobile = innerWidth < 1056;
|
||||||
$: components = $layout.children.filter(
|
$: components = $layout.children.filter(
|
||||||
(child) => child.title === "components",
|
(child) => child.title === "components"
|
||||||
)[0];
|
)[0];
|
||||||
|
$: recipes = $layout.children.filter((child) => child.title === "recipes")[0];
|
||||||
|
|
||||||
$beforeUrlChange(() => {
|
$beforeUrlChange(() => {
|
||||||
if (isMobile) isSideNavOpen = false;
|
if (isMobile) isSideNavOpen = false;
|
||||||
|
@ -64,106 +40,29 @@
|
||||||
<!-- routify:options bundle=true -->
|
<!-- routify:options bundle=true -->
|
||||||
<svelte:window bind:innerWidth />
|
<svelte:window bind:innerWidth />
|
||||||
|
|
||||||
<svelte:body
|
<Theme persist>
|
||||||
on:keydown={(e) => {
|
|
||||||
if (active) return;
|
|
||||||
if (
|
|
||||||
document.activeElement instanceof HTMLInputElement ||
|
|
||||||
document.activeElement instanceof HTMLTextAreaElement
|
|
||||||
) {
|
|
||||||
// Exit early if an inputtable element is already focused.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const isCommandOrControl = e.metaKey || e.ctrlKey;
|
|
||||||
const isCmdK = isCommandOrControl && e.key.toLowerCase() === "k";
|
|
||||||
const isSlash = e.key === "/";
|
|
||||||
|
|
||||||
if (isCmdK || isSlash) {
|
|
||||||
e.preventDefault();
|
|
||||||
active = true;
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<svelte:head>
|
|
||||||
<!-- Tealium/GA Set up -->
|
|
||||||
<script type="text/javascript">
|
|
||||||
window._ibmAnalytics = {
|
|
||||||
settings: {
|
|
||||||
name: "CarbonSvelte",
|
|
||||||
isSpa: true,
|
|
||||||
tealiumProfileName: "ibm-web-app",
|
|
||||||
},
|
|
||||||
onLoad: [["ibmStats.pageview", []]],
|
|
||||||
};
|
|
||||||
digitalData = {
|
|
||||||
page: {
|
|
||||||
pageInfo: {
|
|
||||||
ibm: {
|
|
||||||
siteId: "IBM_" + _ibmAnalytics.settings.name,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
category: {
|
|
||||||
primaryCategory: "PC100",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
<script
|
|
||||||
type="module"
|
|
||||||
defer
|
|
||||||
src="https://1.www.s81c.com/common/carbon-for-ibm-dotcom/tag/v1/latest/footer.min.js"
|
|
||||||
></script>
|
|
||||||
<script
|
|
||||||
src="//1.www.s81c.com/common/stats/ibm-common.js"
|
|
||||||
type="text/javascript"
|
|
||||||
defer
|
|
||||||
></script>
|
|
||||||
</svelte:head>
|
|
||||||
|
|
||||||
<Theme
|
|
||||||
persist
|
|
||||||
bind:theme={$theme}
|
|
||||||
on:update={(e) => {
|
|
||||||
const theme = e.detail.theme;
|
|
||||||
document.documentElement.style.setProperty(
|
|
||||||
"color-scheme",
|
|
||||||
["white", "g10"].includes(theme) ? "light" : "dark",
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Header
|
<Header
|
||||||
aria-label="Navigation"
|
aria-label="Navigation"
|
||||||
href={$url("/")}
|
href="{$url('/')}"
|
||||||
expandedByDefault={true}
|
expandedByDefault="{true}"
|
||||||
bind:isSideNavOpen
|
bind:isSideNavOpen
|
||||||
>
|
>
|
||||||
<svelte:fragment slot="skip-to-content">
|
<svelte:fragment slot="skip-to-content">
|
||||||
<SkipToContent />
|
<SkipToContent />
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
|
|
||||||
<span slot="platform" class="platform-name" class:hidden={active}>
|
<span slot="platform" class="platform-name">
|
||||||
Carbon Components Svelte <code class="code-01"
|
Carbon Components Svelte
|
||||||
>v{process.env.VERSION || ""}</code
|
<code>v{process.env.VERSION || ""}</code>
|
||||||
>
|
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
<HeaderUtilities>
|
<HeaderUtilities>
|
||||||
<HeaderSearch
|
|
||||||
bind:value
|
|
||||||
bind:active
|
|
||||||
placeholder="Search"
|
|
||||||
{results}
|
|
||||||
on:select={(e) => {
|
|
||||||
$goto(e.detail.selectedResult.href);
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
<HeaderActionLink
|
<HeaderActionLink
|
||||||
icon={LogoGithub}
|
icon="{LogoGithub}"
|
||||||
href="https://github.com/carbon-design-system/carbon-components-svelte"
|
href="https://github.com/carbon-design-system/carbon-components-svelte"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
/>
|
/>
|
||||||
<HeaderAction transition={false} bind:isOpen>
|
<HeaderAction transition="{false}" bind:isOpen>
|
||||||
<HeaderPanelLinks>
|
<HeaderPanelLinks>
|
||||||
<HeaderPanelDivider>Carbon Svelte portfolio</HeaderPanelDivider>
|
<HeaderPanelDivider>Carbon Svelte portfolio</HeaderPanelDivider>
|
||||||
<HeaderPanelLink
|
<HeaderPanelLink
|
||||||
|
@ -198,53 +97,70 @@
|
||||||
</HeaderUtilities>
|
</HeaderUtilities>
|
||||||
</Header>
|
</Header>
|
||||||
|
|
||||||
<SideNav bind:isOpen={isSideNavOpen}>
|
<SideNav bind:isOpen="{isSideNavOpen}">
|
||||||
<SideNavItems>
|
<SideNavItems>
|
||||||
{#each components.children.filter((child) => !deprecated.includes(child.title)) as child (child.path)}
|
<SideNavMenu
|
||||||
<SideNavMenuItem
|
expanded="{$isActive($url('')) || $isActive($url('/components'))}"
|
||||||
text={child.title}
|
text="Components"
|
||||||
href={$url(child.path)}
|
>
|
||||||
isSelected={$isActive($url(child.path))}
|
{#each components.children.filter((child) => !deprecated.includes(child.title)) as child, i (child.path)}
|
||||||
>
|
<SideNavMenuItem
|
||||||
{child.title}
|
text="{child.title}"
|
||||||
{#if deprecated.includes(child.title)}
|
href="{$url(child.path)}"
|
||||||
<Tag
|
isSelected="{$isActive($url(child.path))}"
|
||||||
size="sm"
|
>
|
||||||
type="red"
|
{child.title}
|
||||||
style="margin-top: 0; margin-bottom: 0; cursor: inherit"
|
{#if deprecated.includes(child.title)}
|
||||||
>
|
<Tag
|
||||||
Deprecated
|
size="sm"
|
||||||
</Tag>
|
type="red"
|
||||||
{/if}
|
style="margin-top: 0; margin-bottom: 0; cursor: inherit"
|
||||||
{#if new_components.includes(child.title)}
|
>
|
||||||
<Tag
|
Deprecated
|
||||||
size="sm"
|
</Tag>
|
||||||
type="green"
|
{/if}
|
||||||
style="margin-top: 0; margin-bottom: 0; cursor: inherit"
|
{#if new_components.includes(child.title)}
|
||||||
>
|
<Tag
|
||||||
New
|
size="sm"
|
||||||
</Tag>
|
type="green"
|
||||||
{/if}
|
style="margin-top: 0; margin-bottom: 0; cursor: inherit"
|
||||||
</SideNavMenuItem>
|
>
|
||||||
{/each}
|
New
|
||||||
|
</Tag>
|
||||||
|
{/if}
|
||||||
|
</SideNavMenuItem>
|
||||||
|
{/each}
|
||||||
|
</SideNavMenu>
|
||||||
|
<SideNavMenu expanded="{$isActive($url('/recipes'))}" text="Recipes">
|
||||||
|
{#each recipes.children as child, i (child.path)}
|
||||||
|
<SideNavMenuItem
|
||||||
|
href="{$url(child.path)}"
|
||||||
|
isSelected="{$isActive($url(child.path))}"
|
||||||
|
>
|
||||||
|
{child.title}
|
||||||
|
</SideNavMenuItem>
|
||||||
|
{/each}
|
||||||
|
</SideNavMenu>
|
||||||
</SideNavItems>
|
</SideNavItems>
|
||||||
</SideNav>
|
</SideNav>
|
||||||
<slot />
|
<slot />
|
||||||
</Theme>
|
</Theme>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
/** Hide logo to make space for search bar on narrower screens. */
|
|
||||||
@media (max-width: 1056px) {
|
|
||||||
.platform-name.hidden {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.platform-name {
|
.platform-name {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.platform-name code {
|
||||||
|
margin-left: var(--cds-spacing-02);
|
||||||
|
font-size: var(--cds-code-01-font-size);
|
||||||
|
font-weight: var(--cds-code-01-font-weight);
|
||||||
|
letter-spacing: var(--cds-code-01-letter-spacing);
|
||||||
|
line-height: var(--cds-code-01-line-height);
|
||||||
|
color: #c6c6c6;
|
||||||
|
}
|
||||||
|
|
||||||
@media (max-width: 580px) {
|
@media (max-width: 580px) {
|
||||||
.platform-name code {
|
.platform-name code {
|
||||||
display: none;
|
display: none;
|
||||||
|
|
|
@ -10,14 +10,9 @@ components: ["Accordion", "AccordionItem", "AccordionSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Accordion` creates a vertically stacked list of expandable sections that show or hide content. It supports custom titles, different sizes, and various states including disabled and skeleton loading.
|
See the [ExpandableAccordion recipe](/recipes/ExpandableAccordion) for a toggleable accordion component.
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Use the `Accordion` and `AccordionItem` components to compose a collapsible list of
|
|
||||||
items.
|
|
||||||
|
|
||||||
By default, the chevron icon is on the right side of the accordion item.
|
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<AccordionItem title="Natural Language Classifier">
|
<AccordionItem title="Natural Language Classifier">
|
||||||
|
@ -32,11 +27,7 @@ By default, the chevron icon is on the right side of the accordion item.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Left-aligned chevron
|
### Left-aligned chevron
|
||||||
|
|
||||||
The chevron icon can be aligned to the left side of the accordion item by setting
|
|
||||||
the `align` prop to "start". This provides an alternative visual style while
|
|
||||||
maintaining the same functionality.
|
|
||||||
|
|
||||||
<Accordion align="start">
|
<Accordion align="start">
|
||||||
<AccordionItem title="Natural Language Classifier">
|
<AccordionItem title="Natural Language Classifier">
|
||||||
|
@ -51,10 +42,7 @@ maintaining the same functionality.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Custom title slot
|
### Custom title slot
|
||||||
|
|
||||||
Customize the title content by using the `title` slot instead of the `title` prop.
|
|
||||||
This allows for more complex title layouts with multiple elements.
|
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<AccordionItem>
|
<AccordionItem>
|
||||||
|
@ -81,10 +69,7 @@ This allows for more complex title layouts with multiple elements.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## First item open
|
### First item open
|
||||||
|
|
||||||
Set the `open` prop on an `AccordionItem` to have it expanded by default when the
|
|
||||||
accordion is first rendered.
|
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<AccordionItem open title="Natural Language Classifier">
|
<AccordionItem open title="Natural Language Classifier">
|
||||||
|
@ -99,19 +84,7 @@ accordion is first rendered.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Programmatic example
|
### Extra-large size
|
||||||
|
|
||||||
This example demonstrates how to programmatically control the accordion items using
|
|
||||||
the `bind:open` directive. Expand and collapse items based on user
|
|
||||||
interactions or application state.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Accordion/ExpandableAccordion" />
|
|
||||||
|
|
||||||
## Extra-large size
|
|
||||||
|
|
||||||
The accordion can be displayed in an extra-large size by setting the `size` prop to
|
|
||||||
"xl". This provides more visual emphasis and is suitable for prominent content
|
|
||||||
sections.
|
|
||||||
|
|
||||||
<Accordion size="xl">
|
<Accordion size="xl">
|
||||||
<AccordionItem title="Natural Language Classifier">
|
<AccordionItem title="Natural Language Classifier">
|
||||||
|
@ -126,11 +99,7 @@ sections.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
For more compact layouts, set the `size` prop to "sm" to display the accordion in a
|
|
||||||
smaller size. This is useful when space is limited or when the accordion is used as
|
|
||||||
a secondary UI element.
|
|
||||||
|
|
||||||
<Accordion size="sm">
|
<Accordion size="sm">
|
||||||
<AccordionItem title="Natural Language Classifier">
|
<AccordionItem title="Natural Language Classifier">
|
||||||
|
@ -145,10 +114,7 @@ a secondary UI element.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Disabled
|
### Disabled
|
||||||
|
|
||||||
Set the `disabled` prop on the `Accordion` component to disable all items at once.
|
|
||||||
This prevents users from expanding or collapsing any items in the accordion.
|
|
||||||
|
|
||||||
<Accordion disabled>
|
<Accordion disabled>
|
||||||
<AccordionItem title="Natural Language Classifier">
|
<AccordionItem title="Natural Language Classifier">
|
||||||
|
@ -163,11 +129,7 @@ This prevents users from expanding or collapsing any items in the accordion.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Disabled (item)
|
### Disabled (item)
|
||||||
|
|
||||||
Individual accordion items can be disabled by setting the `disabled` prop on
|
|
||||||
specific `AccordionItem` components. This allows for more granular control over
|
|
||||||
which items are interactive.
|
|
||||||
|
|
||||||
<Accordion>
|
<Accordion>
|
||||||
<AccordionItem disabled title="Natural Language Classifier">
|
<AccordionItem disabled title="Natural Language Classifier">
|
||||||
|
@ -182,47 +144,27 @@ which items are interactive.
|
||||||
</AccordionItem>
|
</AccordionItem>
|
||||||
</Accordion>
|
</Accordion>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
The skeleton state provides a loading placeholder for the accordion. It displays a
|
|
||||||
simplified version of the component while content is being loaded.
|
|
||||||
|
|
||||||
<Accordion skeleton />
|
<Accordion skeleton />
|
||||||
|
|
||||||
## Skeleton (left-aligned chevron)
|
### Skeleton (left-aligned chevron)
|
||||||
|
|
||||||
The skeleton state can be combined with the left-aligned chevron style by setting
|
|
||||||
both the `skeleton` and `align="start"` props.
|
|
||||||
|
|
||||||
<Accordion skeleton align="start" />
|
<Accordion skeleton align="start" />
|
||||||
|
|
||||||
## Skeleton (custom count)
|
### Skeleton (custom count)
|
||||||
|
|
||||||
By default, the skeleton state displays 4 items.
|
|
||||||
|
|
||||||
Specify the number of skeleton items to display using the `count` prop. This is
|
|
||||||
useful when you know the exact number of items that will be loaded.
|
|
||||||
|
|
||||||
<Accordion skeleton count={3} />
|
<Accordion skeleton count={3} />
|
||||||
|
|
||||||
## Skeleton (closed)
|
### Skeleton (closed)
|
||||||
|
|
||||||
By default, the first skeleton item is open. The skeleton state can be displayed
|
|
||||||
in a collapsed state by setting `open={false}`.
|
|
||||||
|
|
||||||
<Accordion skeleton open={false} />
|
<Accordion skeleton open={false} />
|
||||||
|
|
||||||
## Skeleton (extra-large)
|
### Skeleton (extra-large)
|
||||||
|
|
||||||
The skeleton state supports the extra-large size variant, maintaining visual
|
|
||||||
consistency with the active component states.
|
|
||||||
|
|
||||||
<Accordion skeleton size="xl" />
|
<Accordion skeleton size="xl" />
|
||||||
|
|
||||||
## Skeleton (small)
|
### Skeleton (small)
|
||||||
|
|
||||||
The skeleton state also supports the small size variant, providing a compact
|
|
||||||
loading placeholder for space-constrained layouts.
|
|
||||||
|
|
||||||
<Accordion skeleton size="sm" />
|
<Accordion skeleton size="sm" />
|
||||||
|
|
||||||
|
|
|
@ -3,67 +3,65 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `AspectRatio` component maintains consistent proportions for content across different screen sizes. It's particularly useful for images, videos, and other media that need to preserve their aspect ratio when resizing.
|
The `AspectRatio` component is useful for constraining fluid content within an aspect ratio. To demo this, resize your browser for the examples below.
|
||||||
|
|
||||||
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
||||||
|
|
||||||
## Default
|
### Default (2x1)
|
||||||
|
|
||||||
Display a 2:1 aspect ratio container by default.
|
|
||||||
|
|
||||||
<AspectRatio>
|
<AspectRatio>
|
||||||
2x1
|
2x1
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 2x3
|
### Ratio 2x3
|
||||||
|
|
||||||
<AspectRatio ratio="2x3">
|
<AspectRatio ratio="2x3">
|
||||||
2x3
|
2x3
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 16x9
|
### Ratio 16x9
|
||||||
|
|
||||||
<AspectRatio ratio="16x9">
|
<AspectRatio ratio="16x9">
|
||||||
16x9
|
16x9
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 4x3
|
### Ratio 4x3
|
||||||
|
|
||||||
<AspectRatio ratio="4x3">
|
<AspectRatio ratio="4x3">
|
||||||
4x3
|
4x3
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 1x1
|
### Ratio 1x1
|
||||||
|
|
||||||
<AspectRatio ratio="1x1">
|
<AspectRatio ratio="1x1">
|
||||||
1x1
|
1x1
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 3x4
|
### Ratio 3x4
|
||||||
|
|
||||||
<AspectRatio ratio="3x4">
|
<AspectRatio ratio="3x4">
|
||||||
3x4
|
3x4
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 3x2
|
### Ratio 3x2
|
||||||
|
|
||||||
<AspectRatio ratio="3x2">
|
<AspectRatio ratio="3x2">
|
||||||
3x2
|
3x2
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 9x16
|
### Ratio 9x16
|
||||||
|
|
||||||
<AspectRatio ratio="9x16">
|
<AspectRatio ratio="9x16">
|
||||||
9x16
|
9x16
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Ratio 1x2
|
### Ratio 1x2
|
||||||
|
|
||||||
<AspectRatio ratio="1x2">
|
<AspectRatio ratio="1x2">
|
||||||
1x2
|
1x2
|
||||||
</AspectRatio>
|
</AspectRatio>
|
||||||
|
|
||||||
## Tile (16x9)
|
### Tile (16x9)
|
||||||
|
|
||||||
<AspectRatio ratio="16x9">
|
<AspectRatio ratio="16x9">
|
||||||
<Tile style="height: 100%">Content</Tile>
|
<Tile style="height: 100%">Content</Tile>
|
||||||
|
|
|
@ -12,11 +12,9 @@ components: ["Breadcrumb", "BreadcrumbItem"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Breadcrumb` displays a hierarchical navigation trail that shows users their current location within an application. It supports current page indication, trailing slash customization, and overflow handling for long navigation paths.
|
See the [Breadcrumbs recipe](/recipes/Breadcrumbs) for a reusable breadcrumbs component.
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Display a hierarchical navigation trail with slashes between items. Mark the current page with `isCurrentPage`.
|
|
||||||
|
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
<BreadcrumbItem href="/">Dashboard</BreadcrumbItem>
|
<BreadcrumbItem href="/">Dashboard</BreadcrumbItem>
|
||||||
|
@ -24,18 +22,14 @@ Display a hierarchical navigation trail with slashes between items. Mark the cur
|
||||||
<BreadcrumbItem href="/reports/2019" isCurrentPage>2019</BreadcrumbItem>
|
<BreadcrumbItem href="/reports/2019" isCurrentPage>2019</BreadcrumbItem>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
|
|
||||||
## No trailing slash
|
### No trailing slash
|
||||||
|
|
||||||
Remove the trailing slash from the last breadcrumb item using `noTrailingSlash`.
|
|
||||||
|
|
||||||
<Breadcrumb noTrailingSlash>
|
<Breadcrumb noTrailingSlash>
|
||||||
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
||||||
<BreadcrumbItem href="/profile" isCurrentPage>Profile</BreadcrumbItem>
|
<BreadcrumbItem href="/profile" isCurrentPage>Profile</BreadcrumbItem>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
|
|
||||||
## Overflow menu
|
### Overflow menu
|
||||||
|
|
||||||
Add an `OverflowMenu` to handle long breadcrumb trails. Use `OverflowMenuItem` components for menu options.
|
|
||||||
|
|
||||||
<Breadcrumb>
|
<Breadcrumb>
|
||||||
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
<BreadcrumbItem href="/">Home</BreadcrumbItem>
|
||||||
|
@ -49,12 +43,6 @@ Add an `OverflowMenu` to handle long breadcrumb trails. Use `OverflowMenuItem` c
|
||||||
<BreadcrumbItem href="/api/data/latest/usage" isCurrentPage>Usage</BreadcrumbItem>
|
<BreadcrumbItem href="/api/data/latest/usage" isCurrentPage>Usage</BreadcrumbItem>
|
||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
|
|
||||||
## Breadcrumb trail
|
### Skeleton
|
||||||
|
|
||||||
<FileSource src="/framed/Breadcrumbs/Breadcrumbs" />
|
|
||||||
|
|
||||||
## Skeleton
|
|
||||||
|
|
||||||
Display a loading state with `skeleton` prop. Use `count` to specify the number of items.
|
|
||||||
|
|
||||||
<Breadcrumb noTrailingSlash skeleton count={3} />
|
<Breadcrumb noTrailingSlash skeleton count={3} />
|
|
@ -1,12 +1,12 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {
|
import {
|
||||||
UnorderedList, ListItem
|
Breakpoint, UnorderedList, ListItem
|
||||||
} from "carbon-components-svelte";
|
} from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The Carbon Design System [grid implementation](https://carbondesignsystem.com/guidelines/2x-grid/implementation#responsive-options) defines five responsive breakpoints:
|
The [Carbon Design System grid implementation](https://carbondesignsystem.com/guidelines/2x-grid/implementation#responsive-options) defines five responsive breakpoints:
|
||||||
|
|
||||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||||
<ListItem><strong>Small</strong>: less than 672px</ListItem>
|
<ListItem><strong>Small</strong>: less than 672px</ListItem>
|
||||||
|
@ -18,7 +18,7 @@ The Carbon Design System [grid implementation](https://carbondesignsystem.com/gu
|
||||||
|
|
||||||
This utility component uses the [Window.matchMedia API](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) to declaratively determine the current Carbon breakpoint size.
|
This utility component uses the [Window.matchMedia API](https://developer.mozilla.org/en-US/docs/Web/API/Window/matchMedia) to declaratively determine the current Carbon breakpoint size.
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Bind to the `size` prop to determine the current breakpoint size. Possible values include: `"sm" | "md" | "lg" | "xlg" | "max"`.
|
Bind to the `size` prop to determine the current breakpoint size. Possible values include: `"sm" | "md" | "lg" | "xlg" | "max"`.
|
||||||
|
|
||||||
|
@ -26,10 +26,10 @@ The `"on:change"` event will fire when the size is initially determined and when
|
||||||
|
|
||||||
<FileSource src="/framed/Breakpoint/Breakpoint" />
|
<FileSource src="/framed/Breakpoint/Breakpoint" />
|
||||||
|
|
||||||
## Store and Breakpoint Values
|
### Store and Breakpoint Values
|
||||||
|
|
||||||
Use `breakpointObserver` as an alternative to the component to get the current size as a Svelte store. The store provides two additional functions that create derived stores returning a `boolean` indicating whether the size is smaller/larger than a certain breakpoint.
|
As an alternative to the component, `breakpointObserver` can be used to get the current size as a Svelte store. The store has two additional functions which create derived stores that return a `boolean` indicating whether the size is smaller/larger than a certain breakpoint.
|
||||||
|
|
||||||
Access the `breakpoints` dictionary to map from `BreakpointSize` to `BreakpointValue`.
|
There also exists a `breakpoints` dictionary mapping from `BreakpointSize` to `BreakpointValue`.
|
||||||
|
|
||||||
<FileSource src="/framed/Breakpoint/BreakpointObserver" />
|
<FileSource src="/framed/Breakpoint/BreakpointObserver" />
|
||||||
|
|
|
@ -4,123 +4,91 @@
|
||||||
import TrashCan from "carbon-icons-svelte/lib/TrashCan.svelte";
|
import TrashCan from "carbon-icons-svelte/lib/TrashCan.svelte";
|
||||||
import Login from "carbon-icons-svelte/lib/Login.svelte";
|
import Login from "carbon-icons-svelte/lib/Login.svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
|
|
||||||
|
let index = 1;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Buttons trigger actions in the interface. Use them to submit forms, navigate between pages, or perform specific tasks. Choose from different styles and sizes to match the importance and context of each action.
|
### Primary button
|
||||||
|
|
||||||
## Primary button
|
|
||||||
|
|
||||||
The default button style is primary. This should be used for primary actions.
|
|
||||||
|
|
||||||
<Button>Primary button</Button>
|
<Button>Primary button</Button>
|
||||||
|
|
||||||
## Secondary button
|
### Secondary button
|
||||||
|
|
||||||
Set `kind="secondary"` for secondary actions.
|
|
||||||
|
|
||||||
<Button kind="secondary">Secondary button</Button>
|
<Button kind="secondary">Secondary button</Button>
|
||||||
|
|
||||||
## Tertiary button
|
### Tertiary button
|
||||||
|
|
||||||
Set `kind="tertiary"` for tertiary actions.
|
|
||||||
|
|
||||||
<Button kind="tertiary">Tertiary button</Button>
|
<Button kind="tertiary">Tertiary button</Button>
|
||||||
|
|
||||||
## Ghost button
|
### Ghost button
|
||||||
|
|
||||||
Set `kind="ghost"` for ghost-style buttons.
|
|
||||||
|
|
||||||
<Button kind="ghost">Ghost button</Button>
|
<Button kind="ghost">Ghost button</Button>
|
||||||
|
|
||||||
## Danger button
|
### Danger button
|
||||||
|
|
||||||
Set `kind="danger"` for destructive actions.
|
|
||||||
|
|
||||||
<Button kind="danger">Danger button</Button>
|
<Button kind="danger">Danger button</Button>
|
||||||
|
|
||||||
## Danger tertiary button
|
### Danger tertiary button
|
||||||
|
|
||||||
Set `kind="danger-tertiary"` for less prominent destructive actions.
|
|
||||||
|
|
||||||
<Button kind="danger-tertiary">Danger tertiary button</Button>
|
<Button kind="danger-tertiary">Danger tertiary button</Button>
|
||||||
|
|
||||||
## Danger tertiary, icon-only button
|
### Danger tertiary, icon-only button
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
Provide an <strong>iconDescription</strong> for accessibility. This text will be used as the button's tooltip and screen reader label.
|
You must provide an <strong>iconDescription</strong> for the button tooltip.
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
<Button kind="danger-tertiary" iconDescription="Delete" icon={TrashCan} />
|
<Button kind="danger-tertiary"iconDescription="Delete" icon={TrashCan} />
|
||||||
|
|
||||||
## Danger ghost button
|
### Danger ghost button
|
||||||
|
|
||||||
Set `kind="danger-ghost"` for ghost-style destructive actions.
|
|
||||||
|
|
||||||
<Button kind="danger-ghost">Danger ghost button</Button>
|
<Button kind="danger-ghost">Danger ghost button</Button>
|
||||||
|
|
||||||
## Button with icon
|
### Button with icon
|
||||||
|
|
||||||
Add an icon to the button using the `icon` prop.
|
|
||||||
|
|
||||||
<Button icon={Add}>With icon</Button>
|
<Button icon={Add}>With icon</Button>
|
||||||
|
|
||||||
## Icon-only button
|
### Icon-only button
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
Provide an <strong>iconDescription</strong> for accessibility. This text will be used as the button's tooltip and screen reader label.
|
You must provide an <strong>iconDescription</strong> for the button tooltip.
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
<Button iconDescription="Tooltip text" icon={Add} />
|
<Button iconDescription="Tooltip text" icon={Add} />
|
||||||
|
|
||||||
## Icon-only, link button
|
### Icon-only, link button
|
||||||
|
|
||||||
Set `href` to create an icon-only link button.
|
|
||||||
|
|
||||||
<Button iconDescription="Login" icon={Login} href="#" />
|
<Button iconDescription="Login" icon={Login} href="#" />
|
||||||
|
|
||||||
## Icon-only button (custom tooltip position)
|
### Icon-only button (custom tooltip position)
|
||||||
|
|
||||||
Control the tooltip position and alignment with `tooltipPosition` and `tooltipAlignment`.
|
The tooltip position and alignment can be controlled by `tooltipPosition` and `tooltipAlignment`.
|
||||||
|
|
||||||
<Button tooltipPosition="right" tooltipAlignment="end" iconDescription="Tooltip text" icon={Add} />
|
<Button tooltipPosition="right" tooltipAlignment="end" iconDescription="Tooltip text" icon={Add} />
|
||||||
|
|
||||||
## Selected icon-only, ghost button
|
### Selected icon-only, ghost button
|
||||||
|
|
||||||
Set `isSelected` to `true` to enable the selected state for an icon-only, ghost button.
|
Set `isSelected` to `true` to enable the selected state for an icon-only, ghost button.
|
||||||
|
|
||||||
<FileSource src="/framed/Button/SelectedIconOnlyButton" />
|
<FileSource src="/framed/Button/SelectedIconOnlyButton" />
|
||||||
|
|
||||||
## Link button
|
### Link button
|
||||||
|
|
||||||
Set `href` to render an [anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) instead of a `button` element.
|
If an `href` value is specified, the component will render an [anchor element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) instead of a `button` element.
|
||||||
|
|
||||||
<Button href="#">Link button</Button>
|
<Button href="#">Link button</Button>
|
||||||
|
|
||||||
## Link button with icon
|
### Custom element
|
||||||
|
|
||||||
Similarly, link buttons can have icons.
|
|
||||||
|
|
||||||
<Button href="#" icon={Add}>Link button with icon</Button>
|
|
||||||
|
|
||||||
## Custom element
|
|
||||||
|
|
||||||
By default, the `Button` will render either a `button` or `a` element.
|
|
||||||
|
|
||||||
To render a different element, set `as` to `true` and spread `let:props` to the element.
|
|
||||||
|
|
||||||
<Button as let:props>
|
<Button as let:props>
|
||||||
<p {...props}>Custom element</p>
|
<p {...props}>Custom element</p>
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
## Field size
|
### Field size
|
||||||
|
|
||||||
The default size is "default".
|
|
||||||
|
|
||||||
Set `size="field"` for field-sized buttons.
|
|
||||||
|
|
||||||
<Button size="field">Primary</Button>
|
<Button size="field">Primary</Button>
|
||||||
<Button size="field" kind="secondary">Secondary</Button>
|
<Button size="field" kind="secondary">Secondary</Button>
|
||||||
|
@ -128,9 +96,7 @@ Set `size="field"` for field-sized buttons.
|
||||||
<Button size="field" kind="ghost">Ghost</Button>
|
<Button size="field" kind="ghost">Ghost</Button>
|
||||||
<Button size="field" kind="danger">Danger</Button>
|
<Button size="field" kind="danger">Danger</Button>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Set `size="small"` for small buttons.
|
|
||||||
|
|
||||||
<Button size="small">Primary</Button>
|
<Button size="small">Primary</Button>
|
||||||
<Button size="small" kind="secondary">Secondary</Button>
|
<Button size="small" kind="secondary">Secondary</Button>
|
||||||
|
@ -138,9 +104,7 @@ Set `size="small"` for small buttons.
|
||||||
<Button size="small" kind="ghost">Ghost</Button>
|
<Button size="small" kind="ghost">Ghost</Button>
|
||||||
<Button size="small" kind="danger">Danger</Button>
|
<Button size="small" kind="danger">Danger</Button>
|
||||||
|
|
||||||
## Large size
|
### Large size
|
||||||
|
|
||||||
Set `size="lg"` for large buttons.
|
|
||||||
|
|
||||||
<Button size="lg">Primary</Button>
|
<Button size="lg">Primary</Button>
|
||||||
<Button size="lg" kind="secondary">Secondary</Button>
|
<Button size="lg" kind="secondary">Secondary</Button>
|
||||||
|
@ -148,9 +112,7 @@ Set `size="lg"` for large buttons.
|
||||||
<Button size="lg" kind="ghost">Ghost</Button>
|
<Button size="lg" kind="ghost">Ghost</Button>
|
||||||
<Button size="lg" kind="danger">Danger</Button>
|
<Button size="lg" kind="danger">Danger</Button>
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Set `size="xl"` for extra-large buttons.
|
|
||||||
|
|
||||||
<Button size="xl">Primary</Button>
|
<Button size="xl">Primary</Button>
|
||||||
<Button size="xl" kind="secondary">Secondary</Button>
|
<Button size="xl" kind="secondary">Secondary</Button>
|
||||||
|
@ -158,20 +120,17 @@ Set `size="xl"` for extra-large buttons.
|
||||||
<Button size="xl" kind="ghost">Ghost</Button>
|
<Button size="xl" kind="ghost">Ghost</Button>
|
||||||
<Button size="xl" kind="danger">Danger</Button>
|
<Button size="xl" kind="danger">Danger</Button>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled button
|
||||||
|
|
||||||
Set `disabled` to disable the button.
|
|
||||||
|
|
||||||
<Button disabled>Disabled button</Button>
|
<Button disabled>Disabled button</Button>
|
||||||
<Button disabled iconDescription="Tooltip text" icon={Add} />
|
|
||||||
|
|
||||||
## Expressive styles
|
### Expressive styles
|
||||||
|
|
||||||
Set `expressive` to `true` to use Carbon's expressive typesetting.
|
Set `expressive` to `true` to use Carbon's expressive typesetting.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
Use expressive styles with default, "lg", or "xl" button sizes.
|
Expressive styles only work with the default, "lg", and "xl" button sizes.
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
|
@ -193,18 +152,10 @@ Set `expressive` to `true` to use Carbon's expressive typesetting.
|
||||||
<Button expressive kind="ghost">Ghost</Button>
|
<Button expressive kind="ghost">Ghost</Button>
|
||||||
<Button expressive kind="danger">Danger</Button>
|
<Button expressive kind="danger">Danger</Button>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Set `skeleton` to show a loading state.
|
|
||||||
|
|
||||||
<Button size="xl" skeleton />
|
<Button size="xl" skeleton />
|
||||||
<Button size="lg" skeleton />
|
<Button size="lg" skeleton />
|
||||||
<Button skeleton />
|
<Button skeleton />
|
||||||
<Button skeleton size="field" />
|
<Button skeleton size="field" />
|
||||||
<Button skeleton size="small" />
|
<Button skeleton size="small" />
|
||||||
|
|
||||||
## Programmatic focus
|
|
||||||
|
|
||||||
Bind to the `ref` prop to access the button element for programmatic focus.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Button/ProgrammaticFocus" />
|
|
||||||
|
|
|
@ -1,23 +1,25 @@
|
||||||
|
---
|
||||||
|
source: Button/ButtonSet.svelte
|
||||||
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Button, ButtonSet } from "carbon-components-svelte";
|
import { Button, ButtonSet } from "carbon-components-svelte";
|
||||||
import Login from "carbon-icons-svelte/lib/Login.svelte";
|
import Login from "carbon-icons-svelte/lib/Login.svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Group related buttons together in a set. Use this component to create consistent spacing and alignment between multiple buttons.
|
### Default
|
||||||
|
|
||||||
## Default
|
Buttons in a button set are juxtaposed by default.
|
||||||
|
|
||||||
Place buttons side by side in a horizontal layout.
|
|
||||||
|
|
||||||
<ButtonSet>
|
<ButtonSet>
|
||||||
<Button kind="secondary">Cancel</Button>
|
<Button kind="secondary">Cancel</Button>
|
||||||
<Button>Submit</Button>
|
<Button>Submit</Button>
|
||||||
</ButtonSet>
|
</ButtonSet>
|
||||||
|
|
||||||
## Stacked
|
### Stacked
|
||||||
|
|
||||||
Set `stacked` to `true` to arrange buttons vertically.
|
Set `stacked` to `true` to use the stacked variant.
|
||||||
|
|
||||||
<ButtonSet stacked>
|
<ButtonSet stacked>
|
||||||
<Button icon={Login}>Log in</Button>
|
<Button icon={Login}>Log in</Button>
|
||||||
|
|
|
@ -3,60 +3,44 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Checkboxes let users select one or more options from a list. Use them for multiple-choice questions, settings, or to confirm actions.
|
### Default (unchecked)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a checkbox with a label using `labelText`.
|
|
||||||
|
|
||||||
By default, the checkbox is unchecked.
|
|
||||||
|
|
||||||
<Checkbox labelText="Label text" />
|
<Checkbox labelText="Label text" />
|
||||||
|
|
||||||
## Checked
|
### Checked
|
||||||
|
|
||||||
Set `checked` to `true` to pre-select the checkbox.
|
|
||||||
|
|
||||||
<Checkbox labelText="Label text" checked />
|
<Checkbox labelText="Label text" checked />
|
||||||
|
|
||||||
## Indeterminate
|
### Indeterminate
|
||||||
|
|
||||||
Set `indeterminate` to `true` to show a mixed state, typically used in parent checkboxes with some children selected.
|
|
||||||
|
|
||||||
<Checkbox labelText="Label text" indeterminate />
|
<Checkbox labelText="Label text" indeterminate />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Set `hideLabel` to `true` to visually hide the label while keeping it accessible to screen readers.
|
|
||||||
|
|
||||||
<Checkbox labelText="Label text" hideLabel />
|
<Checkbox labelText="Label text" hideLabel />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled
|
||||||
|
|
||||||
Set `disabled` to `true` to prevent user interaction.
|
|
||||||
|
|
||||||
<Checkbox labelText="Label text" disabled />
|
<Checkbox labelText="Label text" disabled />
|
||||||
|
|
||||||
## Reactive example (bind:checked)
|
### Reactive example (bind:checked)
|
||||||
|
|
||||||
Use two-way binding with `bind:checked` to track the checkbox state.
|
The `checked` prop supports two-way binding.
|
||||||
|
|
||||||
<FileSource src="/framed/Checkbox/CheckboxReactive" />
|
<FileSource src="/framed/Checkbox/CheckboxReactive" />
|
||||||
|
|
||||||
## Reactive example (bind:group)
|
### Reactive example (bind:group)
|
||||||
|
|
||||||
Bind an array of values using `group` to manage multiple checkboxes. This API is inspired by Svelte [group inputs](https://svelte.dev/tutorial/group-inputs).
|
An alternative to `checked` is binding an array of values using `group`. This API in inspired by Svelte [group inputs](https://svelte.dev/tutorial/group-inputs).
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
When using <strong>bind:group</strong>, <strong>bind:checked</strong> only supports one-way binding.
|
If using <strong>bind:group</strong>, <strong>bind:checked</strong> will only support one-way binding.
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
<FileSource src="/framed/Checkbox/MultipleCheckboxes" />
|
<FileSource src="/framed/Checkbox/MultipleCheckboxes" />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Set `skeleton` to `true` to show a loading state.
|
|
||||||
|
|
||||||
<Checkbox skeleton />
|
<Checkbox skeleton />
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
|
---
|
||||||
|
source: Tile/ClickableTile.svelte
|
||||||
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ClickableTile } from "carbon-components-svelte";
|
import { ClickableTile } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Clickable tiles create interactive content areas that link to other pages or trigger actions. Use them to group related content and provide clear navigation targets.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a clickable tile with an `href` to link to another page.
|
|
||||||
|
|
||||||
<ClickableTile href="https://www.carbondesignsystem.com/">
|
<ClickableTile href="https://www.carbondesignsystem.com/">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</ClickableTile>
|
</ClickableTile>
|
||||||
|
|
||||||
## Prevent default behavior
|
### Prevent default behavior
|
||||||
|
|
||||||
Handle the `click` event to override the default link behavior. Use `e.preventDefault()` to stop navigation.
|
Use the forwarded `click` event and invoke `e.preventDefault()` to prevent the native link behavior.
|
||||||
|
|
||||||
<ClickableTile
|
<ClickableTile
|
||||||
href="/"
|
href="/"
|
||||||
|
@ -27,17 +27,13 @@ Handle the `click` event to override the default link behavior. Use `e.preventDe
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</ClickableTile>
|
</ClickableTile>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Set `light` to `true` to use the light color scheme.
|
|
||||||
|
|
||||||
<ClickableTile light href="https://www.carbondesignsystem.com/">
|
<ClickableTile light href="https://www.carbondesignsystem.com/">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</ClickableTile>
|
</ClickableTile>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Set `disabled` to `true` to prevent interaction.
|
|
||||||
|
|
||||||
<ClickableTile disabled href="https://www.carbondesignsystem.com/">
|
<ClickableTile disabled href="https://www.carbondesignsystem.com/">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
|
|
|
@ -27,124 +27,83 @@ let comment = `
|
||||||
`
|
`
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
Code snippets display and copy code examples. They support single-line, multi-line, and inline formats with customizable copy and expand functionality.
|
|
||||||
|
|
||||||
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
||||||
|
|
||||||
|
Please note that the `clipboard.writeText` API is not supported in [IE 11 nor Safari iOS version 13.3 or lower](https://caniuse.com/mdn-api_clipboard_writetext).
|
||||||
|
|
||||||
You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a single-line code snippet by default.
|
### Default (single-line)
|
||||||
|
|
||||||
<CodeSnippet code="npm i carbon-components-svelte" />
|
<CodeSnippet code="yarn add -D carbon-components-svelte" />
|
||||||
|
|
||||||
## Overriding copy functionality
|
### Overriding copy functionality
|
||||||
|
|
||||||
Pass a custom function to the `copy` prop to override the default copy behavior.
|
To override the default copy behavior, pass a custom function to the `copy` prop.
|
||||||
|
|
||||||
In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
||||||
|
|
||||||
<FileSource src="/framed/CodeSnippet/CodeSnippetOverride" />
|
<FileSource src="/framed/CodeSnippet/CodeSnippetOverride" />
|
||||||
|
|
||||||
## Preventing copy functionality
|
### Preventing copy functionality
|
||||||
|
|
||||||
Pass a no-op function to the `copy` prop to disable copying.
|
To prevent text from being copied entirely, pass a no-op function to the `copy` prop.
|
||||||
|
|
||||||
<CodeSnippet code="npm i carbon-components-svelte" copy={() => {}} />
|
<CodeSnippet code="yarn add -D carbon-components-svelte" copy={() => {}} />
|
||||||
|
|
||||||
## Inline
|
### Inline
|
||||||
|
|
||||||
Set `type="inline"` to display code inline with text.
|
|
||||||
|
|
||||||
<CodeSnippet type="inline" code="rm -rf node_modules/" />
|
<CodeSnippet type="inline" code="rm -rf node_modules/" />
|
||||||
|
|
||||||
## Multi-line
|
### Multi-line
|
||||||
|
|
||||||
Set `type="multi"` to display multiple lines of code with expand/collapse functionality.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} />
|
<CodeSnippet type="multi" {code} />
|
||||||
|
|
||||||
## Expanded by default
|
### Custom copy feedback text
|
||||||
|
|
||||||
Set `expanded` to `true` to show the full multi-line code snippet.
|
Use the `feedback` prop to override the default copy button feedback text.
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} expanded />
|
|
||||||
|
|
||||||
## Reactive example
|
|
||||||
|
|
||||||
The multi-line code snippet dispatches "expand" and "collapse" events.
|
|
||||||
|
|
||||||
<FileSource src="/framed/CodeSnippet/CodeSnippetReactive" />
|
|
||||||
|
|
||||||
## Custom copy feedback text
|
|
||||||
|
|
||||||
Set `feedback` to customize the copy button feedback text.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} feedback="Copied to clipboard" />
|
<CodeSnippet type="multi" {code} feedback="Copied to clipboard" />
|
||||||
|
|
||||||
## Hidden copy button
|
### Hidden copy button
|
||||||
|
|
||||||
Set `hideCopyButton` to `true` to hide the copy button.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} hideCopyButton />
|
<CodeSnippet type="multi" {code} hideCopyButton />
|
||||||
|
|
||||||
## Hidden show more button
|
### Disabled
|
||||||
|
|
||||||
Set `showMoreLess` to `false` to hide the expand/collapse button on multi-line snippets.
|
The `disabled` prop applies only to the `"single"` and `"multi"` code snippet types.
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} showMoreLess={false} />
|
<CodeSnippet disabled code="yarn add -D carbon-components-svelte" />
|
||||||
|
|
||||||
## Hidden copy, show more buttons
|
|
||||||
|
|
||||||
Hide both the copy and expand/collapse buttons.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} hideCopyButton showMoreLess={false} />
|
|
||||||
|
|
||||||
## Custom show more/less text
|
|
||||||
|
|
||||||
Set `showMoreText` and `showLessText` to customize the expand/collapse button text.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" {code} showMoreText="Expand" showLessText="Collapse" />
|
|
||||||
|
|
||||||
## Disabled
|
|
||||||
|
|
||||||
Set `disabled` to `true` to disable interaction. This only applies to `"single"` and `"multi"` types.
|
|
||||||
|
|
||||||
<CodeSnippet disabled code="npm i carbon-components-svelte" />
|
|
||||||
<br />
|
<br />
|
||||||
<CodeSnippet disabled type="multi" code="{comment}" />
|
<CodeSnippet disabled type="multi" code="{comment}" />
|
||||||
|
|
||||||
## Wrapped text
|
### Wrapped text
|
||||||
|
|
||||||
By default, the code snippet preserves text formatting and does not wrap text.
|
`wrapText` only applies to the `"multi"` type.
|
||||||
|
|
||||||
Set `wrapText` to `true` to wrap long lines in multi-line snippets.
|
|
||||||
|
|
||||||
<CodeSnippet wrapText type="multi" code="{comment}" />
|
<CodeSnippet wrapText type="multi" code="{comment}" />
|
||||||
|
|
||||||
## Dynamic multi-line code
|
### Dynamic multi-line code
|
||||||
|
|
||||||
Use the `code` prop instead of the default slot for dynamically updated code.
|
For dynamically updated code, you must use the `code` prop instead of the default slot.
|
||||||
|
|
||||||
<FileSource src="/framed/CodeSnippet/DynamicCodeSnippet" />
|
<FileSource src="/framed/CodeSnippet/DynamicCodeSnippet" />
|
||||||
|
|
||||||
## Hidden multi-line code
|
### Hidden multi-line code
|
||||||
|
|
||||||
The "Show more" button relies on the element's computed height. For hidden content, the button won't appear because the height is `0`.
|
There may be cases where your code snippet is hidden in the DOM. The logic to render the "Show more" button relies on the element's computed height. For hidden content, the button will not appear because the computed height is `0`.
|
||||||
|
|
||||||
Re-render the component to fix this issue.
|
The recommended workaround is to re-render the component. See the example below.
|
||||||
|
|
||||||
<FileSource src="/framed/CodeSnippet/HiddenCodeSnippet" />
|
<FileSource src="/framed/CodeSnippet/HiddenCodeSnippet" />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Set `skeleton` to `true` to show a loading state. Defaults to `"single"` type.
|
The default skeleton type is `"single"`.
|
||||||
|
|
||||||
<CodeSnippet skeleton />
|
<CodeSnippet skeleton />
|
||||||
|
|
||||||
## Skeleton (multi-line)
|
### Skeleton (multi-line)
|
||||||
|
|
||||||
Set `type="multi"` with `skeleton` to show a multi-line loading state.
|
|
||||||
|
|
||||||
<CodeSnippet type="multi" skeleton />
|
<CodeSnippet type="multi" skeleton />
|
|
@ -3,17 +3,13 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ComboBox` combines a text input with a dropdown menu to let users select from predefined options or enter custom values. It supports filtering, custom item rendering, and various states.
|
|
||||||
|
|
||||||
`ComboBox` is keyed for performance reasons.
|
`ComboBox` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Create a combobox with a title and placeholder text. Each item requires a unique `id` and `text`.
|
|
||||||
|
|
||||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -22,26 +18,13 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Custom slot
|
### Custom slot
|
||||||
|
|
||||||
Override the default slot to customize how each item displays. Access the item and index through the `let:` directive.
|
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/ComboBoxSlot" />
|
<FileSource src="/framed/ComboBox/ComboBoxSlot" />
|
||||||
|
|
||||||
## Hidden label
|
### Selected id
|
||||||
|
|
||||||
Set `hideLabel` to `true` to visually hide the label while keeping it accessible to screen readers.
|
|
||||||
|
|
||||||
<ComboBox hideLabel titleText="Hidden Label" placeholder="Select contact method"
|
|
||||||
items={[
|
|
||||||
{id: "0", text: "Slack"},
|
|
||||||
{id: "1", text: "Email"},
|
|
||||||
{id: "2", text: "Fax"}
|
|
||||||
]} />
|
|
||||||
|
|
||||||
## Initial selected id
|
|
||||||
|
|
||||||
Set `selectedId` to pre-select an item when the combobox loads.
|
|
||||||
|
|
||||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||||
selectedId="1"
|
selectedId="1"
|
||||||
|
@ -51,41 +34,29 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
See how the combobox responds to user input and selection changes.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/ReactiveComboBox" />
|
<FileSource src="/framed/ComboBox/ReactiveComboBox" />
|
||||||
|
|
||||||
## Clear selection
|
### Clear selection
|
||||||
|
|
||||||
Use `bind:this` to access the component instance and call `ComboBox.clear()` to programmatically clear the selection.
|
To programmatically clear the selection, access the component instance using the [bind:this](https://svelte.dev/docs#bind_element) directive and invoke the `ComboBox.clear()` accessor.
|
||||||
|
|
||||||
Set `focus: false` in the method options to prevent re-focusing the input.
|
Specify `focus: false` in the method options to avoid re-focusing the input.
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/ComboBoxClear" />
|
<FileSource src="/framed/ComboBox/ComboBoxClear" />
|
||||||
|
|
||||||
## Multiple combo boxes
|
### Multiple combo boxes
|
||||||
|
|
||||||
See how to manage multiple comboboxes in a form.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/MultipleComboBox" />
|
<FileSource src="/framed/ComboBox/MultipleComboBox" />
|
||||||
|
|
||||||
## Filterable
|
### Filterable
|
||||||
|
|
||||||
Enable filtering to let users search through the options.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/FilterableComboBox" />
|
<FileSource src="/framed/ComboBox/FilterableComboBox" />
|
||||||
|
|
||||||
## Filterable with custom label
|
### Top direction
|
||||||
|
|
||||||
Set `itemToString` to customize how items display in the filterable combobox.
|
Set `direction` to `"top"` for the combobox dropdown menu to appear above the input.
|
||||||
|
|
||||||
<FileSource src="/framed/ComboBox/FilterableComboBoxCustomLabel" />
|
|
||||||
|
|
||||||
## Top direction
|
|
||||||
|
|
||||||
Set `direction` to `"top"` to make the dropdown menu appear above the input.
|
|
||||||
|
|
||||||
<ComboBox direction="top" titleText="Contact" placeholder="Select contact method"
|
<ComboBox direction="top" titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -94,9 +65,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Set `light` to `true` to use the light color scheme.
|
|
||||||
|
|
||||||
<ComboBox light titleText="Contact" placeholder="Select contact method"
|
<ComboBox light titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -105,9 +74,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Set `size` to `"xl"` for an extra-large combobox.
|
|
||||||
|
|
||||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||||
size="xl"
|
size="xl"
|
||||||
|
@ -117,9 +84,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Set `size` to `"sm"` for a small combobox.
|
|
||||||
|
|
||||||
<ComboBox titleText="Contact" placeholder="Select contact method"
|
<ComboBox titleText="Contact" placeholder="Select contact method"
|
||||||
size="sm"
|
size="sm"
|
||||||
|
@ -129,9 +94,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Set `invalid` to `true` and provide `invalidText` to show an error message.
|
|
||||||
|
|
||||||
<ComboBox invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" placeholder="Select contact method"
|
<ComboBox invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -140,9 +103,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Set `warn` to `true` and provide `warnText` to show a warning message.
|
|
||||||
|
|
||||||
<ComboBox warn warnText="This contact method is not associated with your account" titleText="Contact" placeholder="Select contact method"
|
<ComboBox warn warnText="This contact method is not associated with your account" titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -151,9 +112,7 @@ items={[
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled
|
||||||
|
|
||||||
Set `disabled` to `true` to prevent interaction with the combobox.
|
|
||||||
|
|
||||||
<ComboBox disabled titleText="Contact" placeholder="Select contact method"
|
<ComboBox disabled titleText="Contact" placeholder="Select contact method"
|
||||||
items={[
|
items={[
|
||||||
|
@ -161,17 +120,3 @@ items={[
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}
|
{id: "2", text: "Fax"}
|
||||||
]} />
|
]} />
|
||||||
|
|
||||||
## Disabled items
|
|
||||||
|
|
||||||
Set `disabled: true` in an item object to disable specific options.
|
|
||||||
|
|
||||||
<ComboBox
|
|
||||||
titleText="Contact"
|
|
||||||
placeholder="Select contact method"
|
|
||||||
items={[
|
|
||||||
{ id: "0", text: "Slack" },
|
|
||||||
{ id: "1", text: "Email", disabled: true },
|
|
||||||
{ id: "2", text: "Fax" },
|
|
||||||
]}
|
|
||||||
/>
|
|
|
@ -6,16 +6,12 @@ components: ["ComposedModal", "ModalHeader", "ModalBody", "ModalFooter"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ComposedModal` lets you build custom modals by combining `ModalHeader`, `ModalBody`, and `ModalFooter` components. Use it to create focused interactions that require user attention or input.
|
### Composed modal
|
||||||
|
|
||||||
## Composed modal
|
|
||||||
|
|
||||||
Create a modal with a header, body, and footer. Each section can be customized independently.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ComposedModal" />
|
<FileSource src="/framed/Modal/ComposedModal" />
|
||||||
|
|
||||||
## Multiple secondary buttons
|
### Multiple secondary buttons
|
||||||
|
|
||||||
Set `secondaryButtons` in `ModalFooter` to create a 3-button modal. This prop replaces `secondaryButtonText` and takes a tuple of two button configurations.
|
Use the `secondaryButtons` prop in `ModalFooter` to render two secondary buttons for a "3-button modal". The prop is a 2-tuple type that supersedes `secondaryButtonText`.
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/3ButtonComposedModal" />
|
<FileSource src="/framed/Modal/3ButtonComposedModal" />
|
|
@ -9,20 +9,14 @@ components: ["ContentSwitcher", "Switch"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ContentSwitcher` lets users switch between different views or sections of content. Use it to organize related content into distinct categories or states.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a content switcher with `Switch` components. Each switch needs a `text` prop.
|
|
||||||
|
|
||||||
<ContentSwitcher>
|
<ContentSwitcher>
|
||||||
<Switch text="Latest news" />
|
<Switch text="Latest news" />
|
||||||
<Switch text="Trending" />
|
<Switch text="Trending" />
|
||||||
</ContentSwitcher>
|
</ContentSwitcher>
|
||||||
|
|
||||||
## Initial selected index
|
### Initial selected index
|
||||||
|
|
||||||
Set `selectedIndex` to pre-select a switch when the content switcher loads.
|
|
||||||
|
|
||||||
<ContentSwitcher selectedIndex={1}>
|
<ContentSwitcher selectedIndex={1}>
|
||||||
<Switch text="Latest news" />
|
<Switch text="Latest news" />
|
||||||
|
@ -30,17 +24,11 @@ Set `selectedIndex` to pre-select a switch when the content switcher loads.
|
||||||
<Switch text="Recommended" />
|
<Switch text="Recommended" />
|
||||||
</ContentSwitcher>
|
</ContentSwitcher>
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
This example demonstrates how to programmatically control the content switcher using
|
|
||||||
the `bind:selectedIndex` directive. Update the selected index based on user
|
|
||||||
interactions or application state.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ContentSwitcher/ContentSwitcherReactive" />
|
<FileSource src="/framed/ContentSwitcher/ContentSwitcherReactive" />
|
||||||
|
|
||||||
## Custom switch slot
|
### Custom switch slot
|
||||||
|
|
||||||
Override the default slot in `Switch` to customize how each option displays.
|
|
||||||
|
|
||||||
<ContentSwitcher>
|
<ContentSwitcher>
|
||||||
<Switch>
|
<Switch>
|
||||||
|
@ -55,27 +43,21 @@ Override the default slot in `Switch` to customize how each option displays.
|
||||||
</Switch>
|
</Switch>
|
||||||
</ContentSwitcher>
|
</ContentSwitcher>
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Set `size` to `"xl"` for an extra-large content switcher.
|
|
||||||
|
|
||||||
<ContentSwitcher size="xl">
|
<ContentSwitcher size="xl">
|
||||||
<Switch text="All" />
|
<Switch text="All" />
|
||||||
<Switch text="Archived" />
|
<Switch text="Archived" />
|
||||||
</ContentSwitcher>
|
</ContentSwitcher>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Set `size` to `"sm"` for a small content switcher.
|
|
||||||
|
|
||||||
<ContentSwitcher size="sm">
|
<ContentSwitcher size="sm">
|
||||||
<Switch text="All" />
|
<Switch text="All" />
|
||||||
<Switch text="Archived" />
|
<Switch text="Archived" />
|
||||||
</ContentSwitcher>
|
</ContentSwitcher>
|
||||||
|
|
||||||
## Disabled
|
### Disabled
|
||||||
|
|
||||||
Set `disabled` to `true` on individual switches to prevent interaction.
|
|
||||||
|
|
||||||
<ContentSwitcher>
|
<ContentSwitcher>
|
||||||
<Switch disabled text="All" />
|
<Switch disabled text="All" />
|
||||||
|
|
|
@ -6,32 +6,26 @@ components: ["ContextMenu", "ContextMenuGroup", "ContextMenuRadioGroup", "Contex
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ContextMenu` displays a menu when users right-click. Use it to provide quick access to contextual actions or options.
|
|
||||||
|
|
||||||
In the examples, right click anywhere within the iframe.
|
In the examples, right click anywhere within the iframe.
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
The context menu appears when right-clicking anywhere in the window. Use `ContextMenuOption` for menu items and `ContextMenuDivider` for visual separation.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ContextMenu/ContextMenu" />
|
|
||||||
|
|
||||||
## Custom target
|
|
||||||
|
|
||||||
By default, the context menu will trigger when right clicking anywhere in the `window`.
|
By default, the context menu will trigger when right clicking anywhere in the `window`.
|
||||||
|
|
||||||
Set `target` to specify which element triggers the context menu.
|
<FileSource src="/framed/ContextMenu/ContextMenu" />
|
||||||
|
|
||||||
|
### Custom target
|
||||||
|
|
||||||
|
Specify a custom `HTMLElement` using the `target` prop.
|
||||||
|
|
||||||
<FileSource src="/framed/ContextMenu/ContextMenuTarget" />
|
<FileSource src="/framed/ContextMenu/ContextMenuTarget" />
|
||||||
|
|
||||||
## Multiple targets
|
### Multiple targets
|
||||||
|
|
||||||
Set `target` to an array of elements to trigger the context menu from multiple sources.
|
The `target` prop also accepts an array of elements.
|
||||||
|
|
||||||
<FileSource src="/framed/ContextMenu/ContextMenuTargets" />
|
<FileSource src="/framed/ContextMenu/ContextMenuTargets" />
|
||||||
|
|
||||||
## Radio groups
|
### Radio groups
|
||||||
|
|
||||||
Use `ContextMenuGroup` and `ContextMenuRadioGroup` to organize related options and create radio button selections.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ContextMenu/ContextMenuGroups" />
|
<FileSource src="/framed/ContextMenu/ContextMenuGroups" />
|
|
@ -3,32 +3,30 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`CopyButton` lets users copy text to their clipboard with a single click. Use it to provide quick access to code snippets, links, or other text content.
|
This component uses the native, asynchronous [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text.
|
||||||
|
|
||||||
This component uses the native [Clipboard API](https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText) to copy text. Override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
Please note that the `clipboard.writeText` API is not supported in [IE 11 nor Safari iOS version 13.3 or lower](https://caniuse.com/mdn-api_clipboard_writetext).
|
||||||
|
|
||||||
## Default
|
You can override the default copy functionality with your own implementation. See [Overriding copy functionality](#overriding-copy-functionality).
|
||||||
|
|
||||||
Create a copy button with the `text` prop to specify what to copy.
|
### Default
|
||||||
|
|
||||||
<CopyButton text="Carbon svelte" />
|
<CopyButton text="Carbon svelte" />
|
||||||
|
|
||||||
## Custom feedback text
|
### Custom feedback text
|
||||||
|
|
||||||
Set `feedback` to customize the message shown after copying.
|
|
||||||
|
|
||||||
<CopyButton text="Carbon svelte" feedback="Copied to clipboard" />
|
<CopyButton text="Carbon svelte" feedback="Copied to clipboard" />
|
||||||
|
|
||||||
## Overriding copy functionality
|
### Overriding copy functionality
|
||||||
|
|
||||||
Pass a custom function to the `copy` prop to override the default copy behavior.
|
To override the default copy behavior, pass a custom function to the `copy` prop.
|
||||||
|
|
||||||
This example uses the NPM package [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
In this example, we use the open source module [clipboard-copy](https://github.com/feross/clipboard-copy) to copy the text instead of the default Clipboard API.
|
||||||
|
|
||||||
<FileSource src="/framed/CopyButton/CopyButtonOverride" />
|
<FileSource src="/framed/CopyButton/CopyButtonOverride" />
|
||||||
|
|
||||||
## Preventing copy functionality
|
### Preventing copy functionality
|
||||||
|
|
||||||
Pass a no-op function to the `copy` prop to disable copying.
|
To prevent text from being copied entirely, pass a no-op function to the `copy` prop.
|
||||||
|
|
||||||
<CopyButton text="This text should not be copied" copy={() => {}} />
|
<CopyButton text="This text should not be copied" copy={() => {}} />
|
|
@ -6,22 +6,25 @@ components: ["DataTable", "Pagination","Toolbar", "ToolbarContent", "ToolbarSear
|
||||||
import { InlineNotification, DataTable, DataTableSkeleton, Pagination, Toolbar, ToolbarContent, ToolbarSearch, ToolbarMenu, ToolbarMenuItem, Button, Link } from "carbon-components-svelte";
|
import { InlineNotification, DataTable, DataTableSkeleton, Pagination, Toolbar, ToolbarContent, ToolbarSearch, ToolbarMenu, ToolbarMenuItem, Button, Link } from "carbon-components-svelte";
|
||||||
import Launch from "carbon-icons-svelte/lib/Launch.svelte";
|
import Launch from "carbon-icons-svelte/lib/Launch.svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
|
|
||||||
|
const pagination = { pageSize: 5, page: 1}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`DataTable` displays structured data in a tabular format. Use it to present large datasets with features like sorting, filtering, pagination, and row selection.
|
`DataTable` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">Every <code>headers</code> object must have a unique "key" property.</div>
|
||||||
This component is keyed for performance.
|
|
||||||
|
|
||||||
Every <strong>headers</strong> object must have a unique "key" property.
|
|
||||||
<div class="body-short-01">Every <strong>rows</strong> object must have a unique "id" property.</div>
|
|
||||||
</div>
|
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
|
<div class="body-short-01">Every <code>rows</code> object must have a unique "id" property.</div>
|
||||||
|
</InlineNotification>
|
||||||
|
|
||||||
Create a basic table by providing `headers` and `rows` data. Match the `key` in headers with the corresponding property in rows.
|
### Default
|
||||||
|
|
||||||
|
The key value in `headers` corresponds to the key value defined in `rows`.
|
||||||
|
|
||||||
|
For example, the header key `"name"` will use the value of `rows[index].name`.
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -76,9 +79,11 @@ Create a basic table by providing `headers` and `rows` data. Match the `key` in
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Slotted cells
|
### Slotted cells
|
||||||
|
|
||||||
Use the `"cell"` slot to customize cell content. Access row and cell data through `let:row` and `let:cell` directives. Use `"cell-header"` slot for header cells.
|
Use the `"cell"` slot to control the display value per table cell. Individual row and cell data are provided through the `let:row` and `let:cell` directives.
|
||||||
|
|
||||||
|
The slot name for the table header cells is `"cell-header"`.
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -148,9 +153,7 @@ Use the `"cell"` slot to customize cell content. Access row and cell data throug
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## With title, description
|
### With title, description
|
||||||
|
|
||||||
Add a title and description to provide context for the table data.
|
|
||||||
|
|
||||||
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -205,9 +208,9 @@ Add a title and description to provide context for the table data.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Slottable title, description
|
### Slottable title, description
|
||||||
|
|
||||||
Use slots to customize the title and description content.
|
The `title` and `description` props are slottable.
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -267,9 +270,9 @@ Use slots to customize the title and description content.
|
||||||
</span>
|
</span>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Static width
|
### Static width
|
||||||
|
|
||||||
Set `useStaticWidth` to `true` to render the table with an auto width instead of 100%.
|
Set `useStaticWidth` to `true` to render the table with a width of "auto" instead of "100%".
|
||||||
|
|
||||||
<DataTable useStaticWidth
|
<DataTable useStaticWidth
|
||||||
title="Load balancers" description="Your organization's active load balancers."
|
title="Load balancers" description="Your organization's active load balancers."
|
||||||
|
@ -325,19 +328,11 @@ title="Load balancers" description="Your organization's active load balancers."
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Custom column widths
|
### Sticky header
|
||||||
|
|
||||||
Specify `width` or `minWidth` in the `headers` object to set column dimensions. This applies a fixed table layout.
|
Set `stickyHeader` to `true` for the header to be fixed in place.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast kind="warning" title="Note:" hideCloseButton>
|
A maximum height will applied to the datatable to force a scrollbar.
|
||||||
<div class="body-short-01">Custom column widths do not work with a <a class="bx--link" href="#sticky-header">sticky header</a>.</div>
|
|
||||||
</InlineNotification>
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableHeaderWidth" />
|
|
||||||
|
|
||||||
## Sticky header
|
|
||||||
|
|
||||||
Set `stickyHeader` to `true` to fix the header in place. This adds a maximum height to force scrolling.
|
|
||||||
|
|
||||||
<DataTable
|
<DataTable
|
||||||
stickyHeader
|
stickyHeader
|
||||||
|
@ -356,9 +351,7 @@ Set `stickyHeader` to `true` to fix the header in place. This adds a maximum hei
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## With toolbar
|
### With toolbar
|
||||||
|
|
||||||
Add a toolbar with search, menu, and actions above the table.
|
|
||||||
|
|
||||||
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
<DataTable title="Load balancers" description="Your organization's active load balancers."
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -427,9 +420,7 @@ Add a toolbar with search, menu, and actions above the table.
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## With toolbar (small size)
|
### With toolbar (small size)
|
||||||
|
|
||||||
Use `size="short"` to create a more compact table with a small toolbar.
|
|
||||||
|
|
||||||
<DataTable size="short" title="Load balancers" description="Your organization's active load balancers."
|
<DataTable size="short" title="Load balancers" description="Your organization's active load balancers."
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -496,23 +487,23 @@ Use `size="short"` to create a more compact table with a small toolbar.
|
||||||
</Toolbar>
|
</Toolbar>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Filterable
|
### Filterable
|
||||||
|
|
||||||
Set `shouldFilterRows` to `true` to enable client-side filtering. The default filter performs string comparisons on cell values.
|
By default, `ToolbarSearch` will not filter `DataTable` rows.
|
||||||
|
|
||||||
For pagination with filtering, bind to `filteredRowIds` and pass its length to `Pagination`'s `totalItems`.
|
Set `shouldFilterRows` to `true` to enable client-side filtering. The default filtering performs a basic string comparison on cell values that are of a string or a number type.
|
||||||
|
|
||||||
|
Note that in-memory filtering is not optimal for large data sets, where you might consider using server-side search.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableFilterable" />
|
<FileSource src="/framed/DataTable/DataTableFilterable" />
|
||||||
|
|
||||||
## Filterable (custom)
|
### Filterable (custom)
|
||||||
|
|
||||||
Pass a function to `shouldFilterRows` to implement custom filtering logic.
|
`shouldFilterRows` also accepts a function and passes it the current row and value. It expects the function to return a boolean.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableFilterCustom" />
|
<FileSource src="/framed/DataTable/DataTableFilterCustom" />
|
||||||
|
|
||||||
## Zebra stripes
|
### Zebra stripes
|
||||||
|
|
||||||
Set `zebra` to `true` to add alternating row colors.
|
|
||||||
|
|
||||||
<DataTable zebra
|
<DataTable zebra
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -567,9 +558,7 @@ Set `zebra` to `true` to add alternating row colors.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Tall rows
|
### Tall rows
|
||||||
|
|
||||||
Set `size="tall"` for increased row height.
|
|
||||||
|
|
||||||
<DataTable size="tall"
|
<DataTable size="tall"
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -624,9 +613,7 @@ Set `size="tall"` for increased row height.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Medium rows
|
### Medium rows
|
||||||
|
|
||||||
Set `size="medium"` for standard row height.
|
|
||||||
|
|
||||||
<DataTable size="medium"
|
<DataTable size="medium"
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -681,9 +668,7 @@ Set `size="medium"` for standard row height.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Short rows
|
### Short rows
|
||||||
|
|
||||||
Set `size="short"` for compact row height.
|
|
||||||
|
|
||||||
<DataTable size="short"
|
<DataTable size="short"
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -738,9 +723,7 @@ Set `size="short"` for compact row height.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Compact rows
|
### Compact rows
|
||||||
|
|
||||||
Set `size="compact"` for minimal row height.
|
|
||||||
|
|
||||||
<DataTable size="compact"
|
<DataTable size="compact"
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -795,9 +778,13 @@ Set `size="compact"` for minimal row height.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Sortable
|
### Sortable
|
||||||
|
|
||||||
Set `sortable` to `true` to enable column sorting. Disable sorting on specific columns by setting `sort: false` in the header object.
|
Set `sortable` to `true` to enable table column sorting.
|
||||||
|
|
||||||
|
To disable sorting on a specific column, set `sort` to `false` in the header object passed to the `headers` prop.
|
||||||
|
|
||||||
|
In the example below, the "Protocol" column is not sortable.
|
||||||
|
|
||||||
<DataTable sortable
|
<DataTable sortable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -852,15 +839,85 @@ Set `sortable` to `true` to enable column sorting. Disable sorting on specific c
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Sortable with pagination
|
### Sortable with pagination
|
||||||
|
|
||||||
Bind to `pageSize` and `page` props of `Pagination` and pass them to `DataTable`.
|
If you want `DataTable` to sort the whole dataset but still display paginated content, you need to pass the whole dataset in the `rows` prop,
|
||||||
|
and then limit displayed content by using `pageSize` and `page` props, which are corresponding to the same props in the `Pagination` component.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTablePagination" />
|
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
||||||
|
headers="{[
|
||||||
|
{ key: "name", value: "Name" },
|
||||||
|
{ key: "protocol", value: "Protocol" },
|
||||||
|
{ key: "port", value: "Port" },
|
||||||
|
{ key: "cost", value: "Cost", display: (cost) => cost + " €" },
|
||||||
|
{
|
||||||
|
key: "expireDate",
|
||||||
|
value: "Expire date",
|
||||||
|
display: (date) => new Date(date).toLocaleString(),
|
||||||
|
sort: (a, b) => new Date(a) - new Date(b),
|
||||||
|
},
|
||||||
|
]}"
|
||||||
|
pageSize={pagination.pageSize}
|
||||||
|
page={pagination.page}
|
||||||
|
rows="{[
|
||||||
|
{
|
||||||
|
id: "a",
|
||||||
|
name: "Load Balancer 3",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 3000,
|
||||||
|
cost: 100,
|
||||||
|
expireDate: "2020-10-21",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "b",
|
||||||
|
name: "Load Balancer 1",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 443,
|
||||||
|
cost: 200,
|
||||||
|
expireDate: "2020-09-10",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "c",
|
||||||
|
name: "Load Balancer 2",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 80,
|
||||||
|
cost: 150,
|
||||||
|
expireDate: "2020-11-24",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "d",
|
||||||
|
name: "Load Balancer 6",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 3000,
|
||||||
|
cost: 250,
|
||||||
|
expireDate: "2020-12-01",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "e",
|
||||||
|
name: "Load Balancer 4",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 443,
|
||||||
|
cost: 550,
|
||||||
|
expireDate: "2021-03-21",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: "f",
|
||||||
|
name: "Load Balancer 5",
|
||||||
|
protocol: "HTTP",
|
||||||
|
port: 80,
|
||||||
|
cost: 400,
|
||||||
|
expireDate: "2020-11-14",
|
||||||
|
},
|
||||||
|
]}"
|
||||||
|
/>
|
||||||
|
<Pagination
|
||||||
|
bind:pageSize={pagination.pageSize}
|
||||||
|
bind:page={pagination.page}
|
||||||
|
totalItems={6}
|
||||||
|
pageSizeInputDisabled
|
||||||
|
/>
|
||||||
|
|
||||||
## Sortable with custom display and sort methods
|
### Sortable with custom display and sort methods
|
||||||
|
|
||||||
Use `display` and `sort` functions in header objects to customize cell rendering and sorting.
|
|
||||||
|
|
||||||
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -927,9 +984,7 @@ Use `display` and `sort` functions in header objects to customize cell rendering
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Sortable with nested object values
|
### Sortable with nested object values
|
||||||
|
|
||||||
Access nested object properties using dot notation in the header key.
|
|
||||||
|
|
||||||
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
<DataTable sortable title="Load balancers" description="Your organization's active load balancers."
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1008,63 +1063,45 @@ Access nested object properties using dot notation in the header key.
|
||||||
]}"
|
]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Programmatic sorting
|
### Empty column with overflow menu
|
||||||
|
|
||||||
Use `sortKey` and `sortDirection` props to control sorting programmatically. Set `sortKey` to a valid header key and `sortDirection` to "none", "ascending", or "descending".
|
Some use cases require an empty column in the table body without a corresponding table header.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableProgrammaticSorting" />
|
For an object in the `headers` array, set `empty` to `true` to render an empty column.
|
||||||
|
|
||||||
## Empty column with overflow menu
|
In the following example, each row in the sortable data table has an overflow menu. There isn't a separate, useless table header column for the overflow menu.
|
||||||
|
|
||||||
Set `empty: true` in a header object to create an empty column. Use this for overflow menus without a header.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableAppendColumns" />
|
<FileSource src="/framed/DataTable/DataTableAppendColumns" />
|
||||||
|
|
||||||
## Selectable rows (checkbox)
|
### Selectable
|
||||||
|
|
||||||
Set `selectable` to `true` for multi-select functionality. Bind to `selectedRowIds` to track selections. Use `inputName` to customize checkbox names.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/SelectableDataTable" />
|
<FileSource src="/framed/DataTable/SelectableDataTable" />
|
||||||
|
|
||||||
## Batch selection
|
### Batch selection
|
||||||
|
|
||||||
Set `batchSelection` to `true` to add a checkbox for selecting all rows. The checkbox shows an indeterminate state when some rows are selected.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableBatchSelection" />
|
<FileSource src="/framed/DataTable/DataTableBatchSelection" />
|
||||||
|
|
||||||
## Batch selection with initial selected rows
|
### Batch selection with initial selected rows
|
||||||
|
|
||||||
Use `selectedRowIds` to specify initially selected rows.
|
Use the `selectedRowIds` prop to specify which rows should be selected.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionInitial" />
|
<FileSource src="/framed/DataTable/DataTableBatchSelectionInitial" />
|
||||||
|
|
||||||
## Batch selection with batch actions toolbar
|
### Selectable with batch actions
|
||||||
|
|
||||||
Add a toolbar for batch actions when rows are selected.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionToolbar" />
|
<FileSource src="/framed/DataTable/DataTableBatchSelectionToolbar" />
|
||||||
|
|
||||||
## Batch selection with controlled toolbar
|
### Selectable (radio)
|
||||||
|
|
||||||
Control the batch actions toolbar with the `active` prop. Prevent default cancel behavior in the `on:cancel` event.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableBatchSelectionToolbarControlled" />
|
|
||||||
|
|
||||||
## Selectable rows (radio)
|
|
||||||
|
|
||||||
Set `radio` to `true` for single-row selection. Bind to `selectedRowIds` to track the selected row. Use `inputName` to customize radio button names.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/RadioSelectableDataTable" />
|
<FileSource src="/framed/DataTable/RadioSelectableDataTable" />
|
||||||
|
|
||||||
## Non-selectable rows
|
### Non-selectable rows
|
||||||
|
|
||||||
Use `nonSelectableRowIds` to prevent selection of specific rows.
|
Use `nonSelectableRowIds` to specify the ids for rows that should not be selectable.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableNonSelectableRows" />
|
<FileSource src="/framed/DataTable/DataTableNonSelectableRows" />
|
||||||
|
|
||||||
## Expandable rows
|
### Expandable
|
||||||
|
|
||||||
Set `expandable` to `true` to make rows expandable. Use the `expanded-row` slot to customize expanded content.
|
|
||||||
|
|
||||||
<DataTable expandable
|
<DataTable expandable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1123,21 +1160,17 @@ Set `expandable` to `true` to make rows expandable. Use the `expanded-row` slot
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Non-expandable rows
|
### Non-expandable rows
|
||||||
|
|
||||||
Use `nonExpandableRowIds` to prevent expansion of specific rows.
|
Use `nonExpandableRowIds` to specify the ids for rows that should not be expandable.
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableNonExpandableRows" />
|
<FileSource src="/framed/DataTable/DataTableNonExpandableRows" />
|
||||||
|
|
||||||
## Expandable (zebra styles)
|
### Expandable (zebra styles)
|
||||||
|
|
||||||
Combine expandable rows with zebra striping.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableExpandableZebra" />
|
<FileSource src="/framed/DataTable/DataTableExpandableZebra" />
|
||||||
|
|
||||||
## Expandable (compact size)
|
### Expandable (compact size)
|
||||||
|
|
||||||
Set `size="compact"` for expandable rows with minimal height.
|
|
||||||
|
|
||||||
<DataTable size="compact" expandable
|
<DataTable size="compact" expandable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1196,9 +1229,7 @@ Set `size="compact"` for expandable rows with minimal height.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Expandable (short size)
|
### Expandable (short size)
|
||||||
|
|
||||||
Set `size="short"` for expandable rows with compact height.
|
|
||||||
|
|
||||||
<DataTable size="short" expandable
|
<DataTable size="short" expandable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1257,9 +1288,7 @@ Set `size="short"` for expandable rows with compact height.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Expandable (tall size)
|
### Expandable (tall size)
|
||||||
|
|
||||||
Set `size="tall"` for expandable rows with increased height.
|
|
||||||
|
|
||||||
<DataTable size="tall" expandable
|
<DataTable size="tall" expandable
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1318,9 +1347,7 @@ Set `size="tall"` for expandable rows with increased height.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Batch expansion
|
### Batch expansion
|
||||||
|
|
||||||
Set `batchExpansion` to `true` to expand and collapse all rows at once.
|
|
||||||
|
|
||||||
<DataTable batchExpansion
|
<DataTable batchExpansion
|
||||||
headers="{[
|
headers="{[
|
||||||
|
@ -1379,56 +1406,42 @@ Set `batchExpansion` to `true` to expand and collapse all rows at once.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
## Expandable and selectable rows
|
### Expandable and selectable
|
||||||
|
|
||||||
Combine `batchExpansion` and `batchSelection` for tables with both expandable and selectable rows.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DataTable/DataTableExpandableSelectable" />
|
<FileSource src="/framed/DataTable/DataTableExpandableSelectable" />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Use `DataTableSkeleton` to show a loading state.
|
|
||||||
|
|
||||||
<DataTableSkeleton />
|
<DataTableSkeleton />
|
||||||
|
|
||||||
## Skeleton with headers, row count
|
### Skeleton with headers, row count
|
||||||
|
|
||||||
Specify headers and row count for the skeleton.
|
|
||||||
|
|
||||||
<DataTableSkeleton headers={["Name", "Protocol", "Port", "Rule"]} rows={10} />
|
<DataTableSkeleton headers={["Name", "Protocol", "Port", "Rule"]} rows={10} />
|
||||||
|
|
||||||
## Skeleton with object headers
|
### Skeleton with object headers
|
||||||
|
|
||||||
Pass header objects to customize the skeleton.
|
`headers` can also be an array of objects. The type is the same as the `headers` prop type used in `DataTable`.
|
||||||
|
|
||||||
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}]} rows={10} />
|
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}]} rows={10} />
|
||||||
|
|
||||||
## Skeleton with empty header
|
### Skeleton with empty header
|
||||||
|
|
||||||
Add an empty header column with `empty: true`.
|
Pass an object with `"empty"` set to `true` to render an empty table header column.
|
||||||
|
|
||||||
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}, { empty: true }]} rows={10} />
|
<DataTableSkeleton headers={[{ value: "Name" }, {value: "Protocol"}, {value:"Port"}, { value: "Rule"}, { empty: true }]} rows={10} />
|
||||||
|
|
||||||
## Skeleton without header, toolbar
|
### Skeleton without header, toolbar
|
||||||
|
|
||||||
Hide the header and toolbar in the skeleton.
|
|
||||||
|
|
||||||
<DataTableSkeleton showHeader={false} showToolbar={false} />
|
<DataTableSkeleton showHeader={false} showToolbar={false} />
|
||||||
|
|
||||||
## Skeleton (tall size)
|
### Skeleton (tall size)
|
||||||
|
|
||||||
Set `size="tall"` for a taller skeleton.
|
|
||||||
|
|
||||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="tall" />
|
<DataTableSkeleton showHeader={false} showToolbar={false} size="tall" />
|
||||||
|
|
||||||
## Skeleton (short size)
|
### Skeleton (short size)
|
||||||
|
|
||||||
Set `size="short"` for a shorter skeleton.
|
|
||||||
|
|
||||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="short" />
|
<DataTableSkeleton showHeader={false} showToolbar={false} size="short" />
|
||||||
|
|
||||||
## Skeleton (compact size)
|
### Skeleton (compact size)
|
||||||
|
|
||||||
Set `size="compact"` for a minimal skeleton.
|
|
||||||
|
|
||||||
<DataTableSkeleton showHeader={false} showToolbar={false} size="compact" />
|
<DataTableSkeleton showHeader={false} showToolbar={false} size="compact" />
|
|
@ -7,7 +7,61 @@ components: ["DatePicker", "DatePickerInput", "DatePickerSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`DatePicker` lets users select a date or date range using a calendar interface. It uses the [flatpickr](https://github.com/flatpickr/flatpickr) library for its calendar implementation.
|
### Default (simple)
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### With helper text
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput labelText="Date of birth" helperText="Example: 01/12/1990" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Hidden label
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput hideLabel labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Light variant
|
||||||
|
|
||||||
|
<DatePicker light>
|
||||||
|
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Extra-large size
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput size="xl" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Small size
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput size="sm" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Invalid state
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput invalid invalidText="Invalid date" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Warning state
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput warn warnText="This info will not be stored" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Disabled state
|
||||||
|
|
||||||
|
<DatePicker>
|
||||||
|
<DatePickerInput disabled labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
||||||
|
</DatePicker>
|
||||||
|
|
||||||
|
### Single
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
|
@ -15,100 +69,22 @@ components: ["DatePicker", "DatePickerInput", "DatePickerSkeleton"]
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Single
|
|
||||||
|
|
||||||
Set `datePickerType` to `"single"` for single date selection.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DatePicker/DatePickerSingle" />
|
<FileSource src="/framed/DatePicker/DatePickerSingle" />
|
||||||
|
|
||||||
## Range
|
### Range
|
||||||
|
|
||||||
Set `datePickerType` to `"range"` to enable date range selection.
|
|
||||||
|
|
||||||
<FileSource src="/framed/DatePicker/DatePickerRange" />
|
<FileSource src="/framed/DatePicker/DatePickerRange" />
|
||||||
|
|
||||||
## DatePicker in a modal
|
### DatePicker in a modal
|
||||||
|
|
||||||
The calendar is positioned inside the wrapper by default (`flatpickrProps.static: true`). This ensures proper positioning within a [Modal](/components/Modal).
|
Use `flatpickrProps` to set `static: true` for the calendar to be positioned relative to the input element.
|
||||||
|
|
||||||
Set `flatpickrProps.static` to `false` to position the calendar outside the wrapper.
|
This is needed when placing a `DatePicker` inside of a `Modal` component.
|
||||||
|
|
||||||
|
Refer to [flatpickr options](https://flatpickr.js.org/options/) for a full list of config options.
|
||||||
|
|
||||||
<FileSource src="/framed/DatePicker/DatePickerModal" />
|
<FileSource src="/framed/DatePicker/DatePickerModal" />
|
||||||
|
|
||||||
## Simple
|
### Skeleton
|
||||||
|
|
||||||
Create a simple date picker without a dropdown calendar.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## With helper text
|
|
||||||
|
|
||||||
Add helper text to provide additional context or formatting instructions.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput labelText="Date of birth" helperText="Example: 01/12/1990" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Hidden label
|
|
||||||
|
|
||||||
Hide the label while maintaining accessibility.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput hideLabel labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Light variant
|
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
|
||||||
|
|
||||||
<DatePicker light>
|
|
||||||
<DatePickerInput labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Extra-large size
|
|
||||||
|
|
||||||
Use the extra-large size for more prominent date pickers.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput size="xl" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Small size
|
|
||||||
|
|
||||||
Use the small size for compact date pickers.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput size="sm" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Invalid state
|
|
||||||
|
|
||||||
Show an invalid state when the input value is not valid.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput invalid invalidText="Invalid date" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Warning state
|
|
||||||
|
|
||||||
Show a warning state to indicate potential issues with the input.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput warn warnText="This info will not be stored" labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Disabled state
|
|
||||||
|
|
||||||
Disable the date picker to prevent user interaction.
|
|
||||||
|
|
||||||
<DatePicker>
|
|
||||||
<DatePickerInput disabled labelText="Date of birth" placeholder="mm/dd/yyyy" />
|
|
||||||
</DatePicker>
|
|
||||||
|
|
||||||
## Skeleton
|
|
||||||
|
|
||||||
Show a loading state with the skeleton component.
|
|
||||||
|
|
||||||
<DatePickerSkeleton />
|
<DatePickerSkeleton />
|
||||||
|
|
|
@ -7,43 +7,33 @@ components: ["Dropdown", "DropdownSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Dropdown` component provides a select input with a dropdown menu. It supports
|
`Dropdown` is keyed for performance reasons.
|
||||||
various states, sizes, and customization options. Each item in the dropdown must
|
|
||||||
have a unique `id` property for proper functionality.
|
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Use the `Dropdown` component to create a select input with a dropdown menu. Each item
|
|
||||||
must have a unique `id` property.
|
|
||||||
|
|
||||||
<Dropdown titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Custom slot
|
### Custom slot
|
||||||
|
|
||||||
Override the default slot to customize the display of each item. Access the item and
|
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||||
index through the `let:` directive.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Dropdown/DropdownSlot" />
|
<FileSource src="/framed/Dropdown/DropdownSlot" />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Hide the label while maintaining accessibility by setting the `hideLabel` prop to
|
|
||||||
`true`. The label will still be available to screen readers.
|
|
||||||
|
|
||||||
<Dropdown hideLabel titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown hideLabel titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Format item display text
|
### Format item display text
|
||||||
|
|
||||||
Format the display text of items using the `itemToString` prop. This function
|
Use the `itemToString` prop to format the display of individual items.
|
||||||
receives the item object and returns the formatted string.
|
|
||||||
|
|
||||||
<Dropdown itemToString={item => {
|
<Dropdown itemToString={item => {
|
||||||
return item.text + ' (' + item.id +')'
|
return item.text + ' (' + item.id +')'
|
||||||
|
@ -51,104 +41,60 @@ receives the item object and returns the formatted string.
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Multiple dropdowns
|
### Multiple dropdowns
|
||||||
|
|
||||||
Create multiple dropdowns that work together. This example demonstrates how to
|
|
||||||
manage the state of multiple dropdowns.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Dropdown/MultipleDropdown" />
|
<FileSource src="/framed/Dropdown/MultipleDropdown" />
|
||||||
|
|
||||||
## Top direction
|
### Top direction
|
||||||
|
|
||||||
Display the dropdown menu above the input by setting the `direction` prop to
|
Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
||||||
`"top"`. This is useful when there's limited space below the input.
|
|
||||||
|
|
||||||
<Dropdown direction="top" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown direction="top" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for dropdowns on dark backgrounds by setting the `light` prop
|
|
||||||
to `true`.
|
|
||||||
|
|
||||||
<Dropdown light titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown light titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Inline variant
|
### Inline variant
|
||||||
|
|
||||||
Display the dropdown inline with other content by setting the `type` prop to
|
|
||||||
`"inline"`. This variant removes the background and border.
|
|
||||||
|
|
||||||
<Dropdown type="inline" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown type="inline" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Increase the size of the dropdown by setting the `size` prop to `"xl"`. This
|
|
||||||
provides more visual emphasis for important selections.
|
|
||||||
|
|
||||||
<Dropdown size="xl" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown size="xl" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Decrease the size of the dropdown by setting the `size` prop to `"sm"`. This is
|
|
||||||
useful for compact layouts or secondary selections.
|
|
||||||
|
|
||||||
<Dropdown size="sm" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown size="sm" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Indicate an invalid selection by setting the `invalid` prop to `true`. Provide
|
|
||||||
feedback to users with the `invalidText` prop.
|
|
||||||
|
|
||||||
<Dropdown invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown invalid invalidText="Secondary contact method must be different from the primary contact" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Indicate a warning state by setting the `warn` prop to `true`. Provide additional
|
|
||||||
context with the `warnText` prop.
|
|
||||||
|
|
||||||
<Dropdown warn warnText="This contact method is not associated with your account" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown warn warnText="This contact method is not associated with your account" titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the entire dropdown by setting the `disabled` prop to `true`. This prevents
|
|
||||||
user interaction with the component.
|
|
||||||
|
|
||||||
<Dropdown disabled titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
<Dropdown disabled titleText="Contact" selectedId="0" items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}" />
|
{id: "2", text: "Fax"}]}" />
|
||||||
|
|
||||||
## Disabled items
|
### Skeleton
|
||||||
|
|
||||||
Disable specific items in the dropdown by setting the `disabled` property to
|
|
||||||
`true` in the item object. This allows for more granular control over available
|
|
||||||
selections.
|
|
||||||
|
|
||||||
<Dropdown
|
|
||||||
selectedId="0"
|
|
||||||
titleText="Contact"
|
|
||||||
items={[
|
|
||||||
{ id: "0", text: "Slack" },
|
|
||||||
{ id: "1", text: "Email", disabled: true },
|
|
||||||
{ id: "2", text: "Fax" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Skeleton
|
|
||||||
|
|
||||||
Display a loading state using the `DropdownSkeleton` component. This provides
|
|
||||||
visual feedback while the dropdown content is being loaded.
|
|
||||||
|
|
||||||
<DropdownSkeleton />
|
<DropdownSkeleton />
|
|
@ -1,94 +1,36 @@
|
||||||
|
---
|
||||||
|
source: Tile/ExpandableTile.svelte
|
||||||
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { ExpandableTile, Button } from "carbon-components-svelte";
|
import { ExpandableTile } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `ExpandableTile` component creates a collapsible content container that can
|
### Default (unexpanded)
|
||||||
show and hide content with a smooth animation. It's ideal for managing content
|
|
||||||
overflow and progressive disclosure of information. The component automatically
|
|
||||||
measures content height using a resize observer.
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create an expandable tile that shows and hides content. The component uses a
|
|
||||||
[resize observer](https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver)
|
|
||||||
to determine the height of the above-the-fold content.
|
|
||||||
|
|
||||||
By default, the tile is collapsed. Use the `above` and `below` slots to define the
|
|
||||||
content that appears before and after expansion.
|
|
||||||
|
|
||||||
<ExpandableTile>
|
|
||||||
<div slot="above">
|
|
||||||
<div>
|
|
||||||
Above the fold content here
|
|
||||||
</div>
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
<div>
|
|
||||||
More above the fold content
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div slot="below">Below the fold content here</div>
|
|
||||||
</ExpandableTile>
|
|
||||||
|
|
||||||
## Custom tile heights
|
|
||||||
|
|
||||||
Set custom heights for the tile content using CSS. This is useful when you need to
|
|
||||||
control the exact dimensions of the visible and hidden content.
|
|
||||||
|
|
||||||
<ExpandableTile>
|
<ExpandableTile>
|
||||||
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
||||||
<div slot="below" style="height: 10rem">Below the fold content here</div>
|
<div slot="below" style="height: 10rem">Below the fold content here</div>
|
||||||
</ExpandableTile>
|
</ExpandableTile>
|
||||||
|
|
||||||
## Expanded
|
### Expanded
|
||||||
|
|
||||||
Display the tile in its expanded state by default by setting the `expanded` prop to
|
|
||||||
`true`.
|
|
||||||
|
|
||||||
<ExpandableTile expanded>
|
<ExpandableTile expanded>
|
||||||
<div slot="above">Above the fold content here</div>
|
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
||||||
<div slot="below">Below the fold content here</div>
|
<div slot="below" style="height: 10rem">Below the fold content here</div>
|
||||||
</ExpandableTile>
|
</ExpandableTile>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for expandable tiles on dark backgrounds by setting the
|
|
||||||
`light` prop to `true`.
|
|
||||||
|
|
||||||
<ExpandableTile light>
|
<ExpandableTile light>
|
||||||
<div slot="above">Above the fold content here</div>
|
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
||||||
<div slot="below">Below the fold content here</div>
|
<div slot="below" style="height: 10rem">Below the fold content here</div>
|
||||||
</ExpandableTile>
|
</ExpandableTile>
|
||||||
|
|
||||||
## With icon labels
|
### With icon labels
|
||||||
|
|
||||||
Customize the expand/collapse button labels using the `tileExpandedLabel` and
|
|
||||||
`tileCollapsedLabel` props.
|
|
||||||
|
|
||||||
<ExpandableTile tileExpandedLabel="View less" tileCollapsedLabel="View more">
|
<ExpandableTile tileExpandedLabel="View less" tileCollapsedLabel="View more">
|
||||||
<div slot="above">Above the fold content here</div>
|
<div slot="above" style="height: 10rem">Above the fold content here</div>
|
||||||
<div slot="below">Below the fold content here</div>
|
<div slot="below" style="height: 10rem">Below the fold content here</div>
|
||||||
</ExpandableTile>
|
|
||||||
|
|
||||||
## With interactive content
|
|
||||||
|
|
||||||
Handle interactive content within the tile by preventing event propagation. This
|
|
||||||
ensures that clicks on interactive elements don't trigger the tile's expand/collapse
|
|
||||||
behavior.
|
|
||||||
|
|
||||||
<ExpandableTile tileExpandedLabel="View less" tileCollapsedLabel="View more">
|
|
||||||
<div slot="above">
|
|
||||||
<a href="/" on:click|preventDefault|stopPropagation={() => console.log("Hello world")}>
|
|
||||||
Native element
|
|
||||||
</a>
|
|
||||||
<br /><br />
|
|
||||||
<Button on:click={e => {
|
|
||||||
e.stopPropagation();
|
|
||||||
console.log("Hello world");
|
|
||||||
}}>
|
|
||||||
Svelte component
|
|
||||||
</Button>
|
|
||||||
</div>
|
|
||||||
<div slot="below">Below the fold content here</div>
|
|
||||||
</ExpandableTile>
|
</ExpandableTile>
|
|
@ -7,47 +7,27 @@ components: ["FileUploaderButton", "FileUploader", "FileUploaderDropContainer",
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `FileUploader` components provide a complete solution for file uploads, including
|
### File uploader (button-only)
|
||||||
a button trigger, drag-and-drop container, and file list display. The components
|
|
||||||
support various states, file validation, and customization options.
|
|
||||||
|
|
||||||
## File uploader (button-only)
|
By default, the file uploader only accepts one file.
|
||||||
|
|
||||||
Create a simple file upload button using `FileUploaderButton`. By default, it
|
Set `multiple` to `true` for multiple files to be uploaded.
|
||||||
accepts a single file. Set `multiple` to `true` to allow multiple file selection.
|
|
||||||
|
|
||||||
<FileUploaderButton labelText="Add file" />
|
<FileUploaderButton labelText="Add files" />
|
||||||
|
|
||||||
## Multiple files
|
### File uploader
|
||||||
|
|
||||||
Enable multiple file selection by setting the `multiple` prop to `true`. This
|
The `FileUploader` wraps `FileUploaderButton` and lists out uploaded files.
|
||||||
allows users to select multiple files at once.
|
|
||||||
|
|
||||||
<FileUploaderButton multiple labelText="Add files" />
|
The example below accepts multiple files with an extension of `.jpg` or `.jpeg`. It sets the status to `"complete"`; by default, the status is `"loading"`.
|
||||||
|
|
||||||
## Custom button kind, size
|
See the [item examples below](#item-uploading) for different statuses.
|
||||||
|
|
||||||
Customize the button appearance using the `kind` and `size` props. The default is
|
|
||||||
a small primary button.
|
|
||||||
|
|
||||||
<FileUploaderButton kind="secondary" size="field" />
|
|
||||||
<FileUploaderButton kind="tertiary" size="default" />
|
|
||||||
<FileUploaderButton kind="danger" size="lg" />
|
|
||||||
<FileUploaderButton kind="danger-tertiary" size="xl" />
|
|
||||||
|
|
||||||
## File uploader
|
|
||||||
|
|
||||||
The `FileUploader` component combines a button trigger with a list of uploaded
|
|
||||||
files. It supports file type restrictions, multiple file selection, and various
|
|
||||||
upload states.
|
|
||||||
|
|
||||||
This example accepts multiple JPEG files and displays them in a completed state.
|
|
||||||
|
|
||||||
<FileUploader multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
<FileUploader multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
||||||
|
|
||||||
## Clear files
|
### Clear files
|
||||||
|
|
||||||
Remove uploaded files from the `FileUploader` component in two ways:
|
There are two ways to clear files in `FileUploader`:
|
||||||
|
|
||||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
||||||
<ListItem>programmatically using the <strong>clearFiles</strong> accessor</ListItem>
|
<ListItem>programmatically using the <strong>clearFiles</strong> accessor</ListItem>
|
||||||
|
@ -56,47 +36,37 @@ Remove uploaded files from the `FileUploader` component in two ways:
|
||||||
|
|
||||||
<FileSource src="/framed/FileUploader/FileUploaderClearFiles" />
|
<FileSource src="/framed/FileUploader/FileUploaderClearFiles" />
|
||||||
|
|
||||||
## File uploader (disabled state)
|
### File uploader (disabled state)
|
||||||
|
|
||||||
Disable the file uploader by setting the `disabled` prop to `true`. This prevents
|
|
||||||
user interaction with the component.
|
|
||||||
|
|
||||||
<FileUploader disabled multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
<FileUploader disabled multiple labelTitle="Upload files" buttonLabel="Add files" labelDescription="Only JPEG files are accepted." accept="{['.jpg', '.jpeg']}" status="complete" />
|
||||||
|
|
||||||
## Item (uploading)
|
### Item (uploading)
|
||||||
|
|
||||||
Display a file upload in progress using the `uploading` status. This shows a
|
|
||||||
loading indicator and the file name.
|
|
||||||
|
|
||||||
<FileUploaderItem name="README.md" status="uploading" />
|
<FileUploaderItem name="README.md" status="uploading" />
|
||||||
|
|
||||||
## Item (complete)
|
### Item (complete)
|
||||||
|
|
||||||
Show a successfully uploaded file using the `complete` status. This displays a
|
|
||||||
checkmark icon next to the file name.
|
|
||||||
|
|
||||||
<FileUploaderItem name="README.md" status="complete" />
|
<FileUploaderItem name="README.md" status="complete" />
|
||||||
|
|
||||||
## Item (edit)
|
### Item (edit)
|
||||||
|
|
||||||
Enable file deletion by setting the status to `"edit"`. Clicking the close icon
|
If the `status` is `"edit"`, clicking the close icon will dispatch a `delete` event.
|
||||||
dispatches a `delete` event with the item's ID.
|
|
||||||
|
The event detail contains the item `id`.
|
||||||
|
|
||||||
<FileUploaderItem id="readme" name="README.md" status="edit" on:delete={(e) => {
|
<FileUploaderItem id="readme" name="README.md" status="edit" on:delete={(e) => {
|
||||||
console.log(e.detail); // "readme"
|
console.log(e.detail); // "readme"
|
||||||
}} />
|
}} />
|
||||||
|
|
||||||
## Item (edit status, invalid state)
|
### Item (edit status, invalid state)
|
||||||
|
|
||||||
Mark a file as invalid while keeping it editable. This shows an error icon and
|
An item can also have an edit status with an invalid state.
|
||||||
allows the user to remove the file.
|
|
||||||
|
|
||||||
<FileUploaderItem invalid id="readme" name="README.md" status="edit" on:delete />
|
<FileUploaderItem invalid id="readme" name="README.md" status="edit" on:delete />
|
||||||
|
|
||||||
## Item (edit status, invalid state with subject, body)
|
### Item (edit status, invalid state with subject, body)
|
||||||
|
|
||||||
Provide detailed error messages for invalid files using the `errorSubject` and
|
Use the `errorSubject` and `errorBody` props to customize the error message.
|
||||||
`errorBody` props. This helps users understand and resolve upload issues.
|
|
||||||
|
|
||||||
<FileUploaderItem
|
<FileUploaderItem
|
||||||
invalid
|
invalid
|
||||||
|
@ -108,22 +78,21 @@ Provide detailed error messages for invalid files using the `errorSubject` and
|
||||||
on:delete
|
on:delete
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Item sizes
|
### Item sizes
|
||||||
|
|
||||||
Customize the size of file uploader items using the `size` prop. The default size
|
The default `FileUploaderItem` size is "default".
|
||||||
is "default".
|
|
||||||
|
|
||||||
<FileUploaderItem size="default" name="README.md" status="uploading" />
|
<FileUploaderItem size="default" name="README.md" status="uploading" />
|
||||||
<FileUploaderItem size="field" name="README.md" status="uploading" />
|
<FileUploaderItem size="field" name="README.md" status="uploading" />
|
||||||
<FileUploaderItem size="small" name="README.md" status="uploading" />
|
<FileUploaderItem size="small" name="README.md" status="uploading" />
|
||||||
|
|
||||||
## Drop container
|
### Drop container
|
||||||
|
|
||||||
Use `FileUploaderDropContainer` for drag-and-drop file uploads. It supports file
|
The `FileUploaderDropContainer` accepts files through click and drop events.
|
||||||
validation and multiple file selection.
|
|
||||||
|
|
||||||
This example accepts files smaller than 1 kB and logs the selected files to the
|
Use the `validateFiles` prop to filter out files before they are set.
|
||||||
console.
|
|
||||||
|
The following example accepts files smaller than 1 kB.
|
||||||
|
|
||||||
<FileUploaderDropContainer
|
<FileUploaderDropContainer
|
||||||
multiple
|
multiple
|
||||||
|
@ -136,9 +105,6 @@ console.
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Display a loading state using the `FileUploaderSkeleton` component. This provides
|
|
||||||
visual feedback while the file uploader content is being loaded.
|
|
||||||
|
|
||||||
<FileUploaderSkeleton />
|
<FileUploaderSkeleton />
|
|
@ -1,24 +1,15 @@
|
||||||
<script>
|
<script>
|
||||||
import {
|
import { FluidForm, FormGroup, TextInput, PasswordInput, Button,} from "carbon-components-svelte";
|
||||||
FluidForm,
|
|
||||||
TextInput,
|
|
||||||
PasswordInput,
|
|
||||||
} from "carbon-components-svelte";
|
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `FluidForm` component provides a fluid-width form layout that adapts to its
|
### Fluid form
|
||||||
container. It's designed for full-width form layouts and works with most Carbon
|
|
||||||
input components. Note that inline input variants cannot be used within a
|
|
||||||
`FluidForm`.
|
|
||||||
|
|
||||||
## Fluid form
|
|
||||||
|
|
||||||
Create a fluid-width form layout using the `FluidForm` component. This example
|
|
||||||
shows a basic login form with required fields.
|
|
||||||
|
|
||||||
<FluidForm>
|
<FluidForm>
|
||||||
<TextInput labelText="User name" placeholder="Enter user name..." required />
|
<TextInput
|
||||||
|
labelText="User name"
|
||||||
|
placeholder="Enter user name..."
|
||||||
|
required />
|
||||||
<PasswordInput
|
<PasswordInput
|
||||||
required
|
required
|
||||||
type="password"
|
type="password"
|
||||||
|
@ -26,11 +17,3 @@ shows a basic login form with required fields.
|
||||||
placeholder="Enter password..."
|
placeholder="Enter password..."
|
||||||
/>
|
/>
|
||||||
</FluidForm>
|
</FluidForm>
|
||||||
|
|
||||||
## Invalid state
|
|
||||||
|
|
||||||
Handle form validation and display error states using the `invalid` and
|
|
||||||
`invalidText` props on form inputs. This example demonstrates how to show
|
|
||||||
validation errors in a fluid form.
|
|
||||||
|
|
||||||
<FileSource src="/framed/FluidForm/FluidFormInvalid" />
|
|
|
@ -14,14 +14,7 @@ components: ["Form", "FormGroup"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Form` component provides a structured way to collect user input. It works with
|
### Form
|
||||||
various form controls like checkboxes, radio buttons, and select menus. The
|
|
||||||
`FormGroup` component helps organize related form controls with a legend.
|
|
||||||
|
|
||||||
## Form
|
|
||||||
|
|
||||||
Create a form with grouped controls using `Form` and `FormGroup`. This example
|
|
||||||
shows a form with checkboxes, radio buttons, and a select menu.
|
|
||||||
|
|
||||||
<Form on:submit>
|
<Form on:submit>
|
||||||
<FormGroup legendText="Checkboxes">
|
<FormGroup legendText="Checkboxes">
|
||||||
|
@ -53,7 +46,7 @@ shows a form with checkboxes, radio buttons, and a select menu.
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<Select id="select-1" labelText="Select menu">
|
<Select id="select-1" labelText="Select menu" value="placeholder-item">
|
||||||
<SelectItem
|
<SelectItem
|
||||||
disabled
|
disabled
|
||||||
hidden
|
hidden
|
||||||
|
@ -68,11 +61,9 @@ shows a form with checkboxes, radio buttons, and a select menu.
|
||||||
<Button type="submit">Submit</Button>
|
<Button type="submit">Submit</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
## Prevent default behavior
|
### Prevent default behavior
|
||||||
|
|
||||||
Handle form submission by preventing the default browser behavior. Use
|
The forwarded `submit` event is not modified. Use `e.preventDefault()` to prevent the native form submission behavior.
|
||||||
`e.preventDefault()` to stop the native form submission and handle the event
|
|
||||||
programmatically.
|
|
||||||
|
|
||||||
<Form on:submit={e => {
|
<Form on:submit={e => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -6,62 +6,34 @@ components: ["Grid", "Row", "Column"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Grid` system provides a responsive, 12-column layout structure. Use `Row` and
|
### Default
|
||||||
`Column` components to create flexible layouts that adapt to different screen
|
|
||||||
sizes. The grid supports various spacing options and column configurations.
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic grid layout with equal-width columns. This example demonstrates the
|
|
||||||
default grid behavior.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/Grid" />
|
<FileSource src="/framed/Grid/Grid" />
|
||||||
|
|
||||||
## Full width
|
### Full width
|
||||||
|
|
||||||
Use the full-width grid variant for layouts that span the entire viewport width.
|
|
||||||
This removes the default max-width constraint.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/FullWidthGrid" />
|
<FileSource src="/framed/Grid/FullWidthGrid" />
|
||||||
|
|
||||||
## Narrow
|
### Narrow
|
||||||
|
|
||||||
Create a more compact grid layout using the narrow variant. This reduces the
|
|
||||||
spacing between columns.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/NarrowGrid" />
|
<FileSource src="/framed/Grid/NarrowGrid" />
|
||||||
|
|
||||||
## Condensed
|
### Condensed
|
||||||
|
|
||||||
Use the condensed variant for even tighter spacing between columns. This is ideal
|
|
||||||
for dense data displays.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/CondensedGrid" />
|
<FileSource src="/framed/Grid/CondensedGrid" />
|
||||||
|
|
||||||
## Responsive
|
### Responsive
|
||||||
|
|
||||||
Build responsive layouts by specifying different column widths for different
|
|
||||||
breakpoints. The grid automatically adjusts based on screen size.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/ResponsiveGrid" />
|
<FileSource src="/framed/Grid/ResponsiveGrid" />
|
||||||
|
|
||||||
## Offset columns
|
### Offset columns
|
||||||
|
|
||||||
Create space between columns using the offset feature. This allows for more
|
|
||||||
flexible layouts without empty columns.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/OffsetColumns" />
|
<FileSource src="/framed/Grid/OffsetColumns" />
|
||||||
|
|
||||||
## Aspect ratio columns
|
### Aspect ratio columns
|
||||||
|
|
||||||
Maintain consistent column heights using aspect ratio columns. This ensures
|
|
||||||
content alignment across different column widths.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/AspectRatioColumns" />
|
<FileSource src="/framed/Grid/AspectRatioColumns" />
|
||||||
|
|
||||||
## Padded columns
|
### Padded columns
|
||||||
|
|
||||||
Add padding to columns using the padded variant. This creates more breathing room
|
|
||||||
between content.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Grid/PaddedGrid" />
|
<FileSource src="/framed/Grid/PaddedGrid" />
|
||||||
|
|
|
@ -5,22 +5,15 @@
|
||||||
let key = 0;
|
let key = 0;
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `ImageLoader` component provides a robust way to load images with built-in
|
This utility component uses the [Image API](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image) to programmatically load an image with slottable loading and error states.
|
||||||
loading and error states. It uses the [Image API](https://developer.mozilla.org/en-US/docs/Web/API/HTMLImageElement/Image)
|
|
||||||
to handle image loading programmatically. The component supports aspect ratios,
|
|
||||||
fade-in animations, and custom loading/error states.
|
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Load an image with the default configuration. The component handles the loading
|
|
||||||
process automatically.
|
|
||||||
|
|
||||||
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
||||||
|
|
||||||
## Slots
|
### Slots
|
||||||
|
|
||||||
Customize the loading and error states using named slots. This example shows how
|
Use the "loading" and "error" named slots to render an element when the image is loading or has an error.
|
||||||
to display a loading indicator and error message.
|
|
||||||
|
|
||||||
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg">
|
<ImageLoader src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg">
|
||||||
<svelte:fragment slot="loading">
|
<svelte:fragment slot="loading">
|
||||||
|
@ -31,34 +24,23 @@ to display a loading indicator and error message.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</ImageLoader>
|
</ImageLoader>
|
||||||
|
|
||||||
## With aspect ratio
|
### With aspect ratio
|
||||||
|
|
||||||
Maintain consistent image dimensions using aspect ratios. The component uses
|
If `ratio` is set, this component uses the [AspectRatio](/components/AspectRatio) to constrain the image.
|
||||||
[AspectRatio](/components/AspectRatio) to constrain the image.
|
|
||||||
|
|
||||||
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`,
|
Supported aspect ratios include `"2x1"`, `"2x3"`, `"16x9"`, `"4x3"`, `"1x1"`, `"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
||||||
`"3x4"`, `"3x2"`, `"9x16"` and `"1x2"`.
|
|
||||||
|
|
||||||
<ImageLoader ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
<ImageLoader ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />
|
||||||
|
|
||||||
## Fade in
|
### Fade in
|
||||||
|
|
||||||
Enable a smooth fade-in animation when the image loads successfully. This provides
|
Set `fadeIn` to `true` to fade in the image if successfully loaded.
|
||||||
a better user experience for image loading.
|
|
||||||
|
|
||||||
<Button kind="ghost" on:click="{() => { key++;}}">Reload image</Button>
|
<Button kind="ghost" on:click="{() => { key++;}}">Reload image</Button>
|
||||||
{#key key}<ImageLoader fadeIn ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />{/key}
|
{#key key}<ImageLoader fadeIn ratio="16x9" src="https://upload.wikimedia.org/wikipedia/commons/5/51/IBM_logo.svg" />{/key}
|
||||||
|
|
||||||
## Programmatic usage
|
### Programmatic usage
|
||||||
|
|
||||||
Control image loading programmatically using component references. This example
|
In this example, a component reference is obtained to programmatically trigger the `loadImage` method.
|
||||||
demonstrates how to trigger image loading manually.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ImageLoader/ProgrammaticImageLoader" />
|
<FileSource src="/framed/ImageLoader/ProgrammaticImageLoader" />
|
||||||
|
|
||||||
## Dynamic image source
|
|
||||||
|
|
||||||
Update the image source dynamically using the same `ImageLoader` instance. This
|
|
||||||
allows for smooth transitions between different images.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ImageLoader/DynamicImageLoader" />
|
|
||||||
|
|
|
@ -1,44 +1,23 @@
|
||||||
---
|
|
||||||
components: ["InlineLoading"]
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { InlineLoading, UnorderedList, ListItem } from "carbon-components-svelte";
|
import { InlineLoading } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `InlineLoading` component provides a compact loading indicator that can be embedded within content. It's ideal for showing progress during inline operations like form submissions or data updates.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic loading indicator with the default configuration.
|
|
||||||
|
|
||||||
<InlineLoading />
|
<InlineLoading />
|
||||||
|
|
||||||
## With description
|
### With description
|
||||||
|
|
||||||
Add a descriptive text to provide context about the loading operation.
|
|
||||||
|
|
||||||
<InlineLoading description="Loading metrics..." />
|
<InlineLoading description="Loading metrics..." />
|
||||||
|
|
||||||
## Status states
|
### Status states
|
||||||
|
|
||||||
The component supports different status states to indicate progress:
|
|
||||||
|
|
||||||
<UnorderedList svx-ignore style="margin-bottom: var(--cds-spacing-08)">
|
|
||||||
<ListItem><strong>active</strong>: Shows an animated loading indicator</ListItem>
|
|
||||||
<ListItem><strong>inactive</strong>: Displays a static state</ListItem>
|
|
||||||
<ListItem><strong>finished</strong>: Shows a success state</ListItem>
|
|
||||||
<ListItem><strong>error</strong>: Displays an error state</ListItem>
|
|
||||||
</UnorderedList>
|
|
||||||
|
|
||||||
<InlineLoading status="active" description="Submitting..." />
|
<InlineLoading status="active" description="Submitting..." />
|
||||||
<InlineLoading status="inactive" description="Cancelling..." />
|
<InlineLoading status="inactive" description="Cancelling..." />
|
||||||
<InlineLoading status="finished" description="Success" />
|
<InlineLoading status="finished" description="Success" />
|
||||||
<InlineLoading status="error" description="An error occurred" />
|
<InlineLoading status="error" description="An error occurred" />
|
||||||
|
|
||||||
## UX example
|
### UX example
|
||||||
|
|
||||||
See how to integrate the loading indicator in a real-world scenario.
|
|
||||||
|
|
||||||
<FileSource src="/framed/InlineLoading/InlineLoadingUx" />
|
<FileSource src="/framed/InlineLoading/InlineLoadingUx" />
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
components: ["InlineNotification", "NotificationActionButton"]
|
source: Notification/InlineNotification.svelte
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -7,55 +7,22 @@ components: ["InlineNotification", "NotificationActionButton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `InlineNotification` component displays contextual messages inline with content. It supports various types of notifications (error, warning, success, info) and can include actions. Use it to provide feedback or important information to users.
|
### Default (error)
|
||||||
|
|
||||||
See [detailed usage](https://carbondesignsystem.com/components/notification/usage).
|
|
||||||
See also: [ToastNotification](ToastNotification)
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic error notification with title and subtitle by default.
|
|
||||||
|
|
||||||
<InlineNotification title="Error:" subtitle="An internal server error occurred." />
|
<InlineNotification title="Error:" subtitle="An internal server error occurred." />
|
||||||
|
|
||||||
## Prevent default close behavior
|
### Slottable title, subtitle
|
||||||
|
|
||||||
The component is controlled, allowing you to prevent the default close behavior using `e.preventDefault()`.
|
|
||||||
|
|
||||||
<InlineNotification title="Error" subtitle="An internal server error occurred." on:close={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
// custom close logic (e.g., transitions)
|
|
||||||
}} />
|
|
||||||
|
|
||||||
## Slottable title and subtitle
|
|
||||||
|
|
||||||
Customize the notification content using slots for more flexibility.
|
|
||||||
|
|
||||||
<InlineNotification>
|
<InlineNotification>
|
||||||
<strong slot="title">Error: </strong>
|
<strong slot="title">Error: </strong>
|
||||||
<strong slot="subtitle">An internal server error occurred.</strong>
|
<strong slot="subtitle">An internal server error occurred.</strong>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Accessible icon descriptions
|
### Hidden close button
|
||||||
|
|
||||||
Make notifications more accessible by providing custom descriptions for icons.
|
|
||||||
|
|
||||||
<InlineNotification
|
|
||||||
title="错误"
|
|
||||||
subtitle="发生内部服务器错误"
|
|
||||||
statusIconDescription="错误图标"
|
|
||||||
closeButtonDescription="关闭通知"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Hidden close button
|
|
||||||
|
|
||||||
Create a persistent notification by hiding the close button.
|
|
||||||
|
|
||||||
<InlineNotification hideCloseButton kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
<InlineNotification hideCloseButton kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
||||||
|
|
||||||
## With actions
|
### With actions
|
||||||
|
|
||||||
Add interactive elements to notifications using the actions slot.
|
|
||||||
|
|
||||||
<InlineNotification kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours.">
|
<InlineNotification kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours.">
|
||||||
<svelte:fragment slot="actions">
|
<svelte:fragment slot="actions">
|
||||||
|
@ -63,9 +30,7 @@ Add interactive elements to notifications using the actions slot.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Notification variants
|
### Notification variants
|
||||||
|
|
||||||
The component supports different notification types:
|
|
||||||
|
|
||||||
<InlineNotification kind="error" title="Error:" subtitle="An internal server error occurred." />
|
<InlineNotification kind="error" title="Error:" subtitle="An internal server error occurred." />
|
||||||
<InlineNotification kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
<InlineNotification kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||||
|
@ -74,9 +39,7 @@ The component supports different notification types:
|
||||||
<InlineNotification kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
<InlineNotification kind="warning" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
||||||
<InlineNotification kind="warning-alt" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
<InlineNotification kind="warning-alt" title="Scheduled maintenance:" subtitle="Maintenance will last 2-4 hours." />
|
||||||
|
|
||||||
## Low contrast
|
### Low contrast
|
||||||
|
|
||||||
Use low contrast variants for less prominent notifications.
|
|
||||||
|
|
||||||
<InlineNotification lowContrast kind="error" title="Error:" subtitle="An internal server error occurred." />
|
<InlineNotification lowContrast kind="error" title="Error:" subtitle="An internal server error occurred." />
|
||||||
<InlineNotification lowContrast kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
<InlineNotification lowContrast kind="info" title="New updates:" subtitle="Restart to get the latest updates." />
|
||||||
|
|
|
@ -8,35 +8,31 @@ components: ["Link", "OutboundLink"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Link` component provides styled hyperlinks with various customization options. It supports different sizes, states, and can include icons. The `OutboundLink` variant automatically handles external links with proper security attributes.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic link with the default styling.
|
|
||||||
|
|
||||||
<Link href="https://www.carbondesignsystem.com/">
|
<Link href="https://www.carbondesignsystem.com/">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
## Target _blank
|
### Target _blank
|
||||||
|
|
||||||
For external links, the component automatically adds security attributes. You can override the `rel` attribute if needed.
|
If setting `target` to `"_blank"`, the `Link` component will automatically set `rel="noopener noreferrer"` to guard against [potential cross-origin security exploits](https://web.dev/external-anchors-use-rel-noopener/).
|
||||||
|
|
||||||
|
You can override the `rel` attribute with a custom value.
|
||||||
|
|
||||||
<Link href="https://www.carbondesignsystem.com/" target="_blank">
|
<Link href="https://www.carbondesignsystem.com/" target="_blank">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
## Outbound link
|
### Outbound link
|
||||||
|
|
||||||
Use `OutboundLink` as a convenient alternative for external links.
|
An alternative to manually setting `target` to `"_blank"` is to use the `OutboundLink`.
|
||||||
|
|
||||||
<OutboundLink href="https://www.carbondesignsystem.com/">
|
<OutboundLink href="https://www.carbondesignsystem.com/">
|
||||||
Carbon Design System
|
Carbon Design System
|
||||||
</OutboundLink>
|
</OutboundLink>
|
||||||
|
|
||||||
## Inline variant
|
### Inline variant
|
||||||
|
|
||||||
Create links that flow naturally with surrounding text.
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
Visit the
|
Visit the
|
||||||
|
@ -45,9 +41,9 @@ Create links that flow naturally with surrounding text.
|
||||||
</Link>.
|
</Link>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Link with icon
|
### Link with icon
|
||||||
|
|
||||||
Add icons to links for better visual context. Note that `inline` must be `false` when using icons.
|
Note that `inline` must be `false` when rendering a link with an icon.
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
Visit the
|
Visit the
|
||||||
|
@ -56,34 +52,28 @@ Add icons to links for better visual context. Note that `inline` must be `false`
|
||||||
</Link>.
|
</Link>.
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Size variants
|
### Large size
|
||||||
|
|
||||||
The component supports different sizes to match your design needs:
|
|
||||||
|
|
||||||
<Link size="lg" href="https://www.carbondesignsystem.com/">
|
<Link size="lg" href="https://www.carbondesignsystem.com/">
|
||||||
Large link
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
||||||
<br />
|
|
||||||
<Link href="https://www.carbondesignsystem.com/">
|
### Small size
|
||||||
Default link
|
|
||||||
</Link>
|
|
||||||
<br />
|
|
||||||
<Link size="sm" href="https://www.carbondesignsystem.com/">
|
<Link size="sm" href="https://www.carbondesignsystem.com/">
|
||||||
Small link
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled
|
||||||
|
|
||||||
Disabled links render as plain text while maintaining accessibility.
|
A `disabled` link will render a `p` tag instead of an anchor element.
|
||||||
|
|
||||||
<Link disabled href="https://www.carbondesignsystem.com/">
|
<Link disabled href="https://www.carbondesignsystem.com/">
|
||||||
Disabled link
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
||||||
|
|
||||||
## Visited styles
|
### Visited styles
|
||||||
|
|
||||||
Show visited state styling for links.
|
|
||||||
|
|
||||||
<Link visited href="https://www.carbondesignsystem.com/">
|
<Link visited href="https://www.carbondesignsystem.com/">
|
||||||
Visited link
|
Carbon Design System
|
||||||
</Link>
|
</Link>
|
|
@ -1,28 +1,16 @@
|
||||||
---
|
|
||||||
components: ["Loading"]
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Loading } from "carbon-components-svelte";
|
import { Loading } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Loading` component provides a full-screen or inline loading indicator. It's ideal for showing progress during page loads or data fetching operations.
|
### Default (with overlay)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a loading indicator with a semi-transparent overlay that covers the entire viewport.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Loading/Loading" />
|
<FileSource src="/framed/Loading/Loading" />
|
||||||
|
|
||||||
## No overlay
|
### No overlay
|
||||||
|
|
||||||
Show a loading indicator without the overlay, allowing interaction with the underlying content.
|
|
||||||
|
|
||||||
<Loading withOverlay={false} />
|
<Loading withOverlay={false} />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Display a more compact loading indicator.
|
|
||||||
|
|
||||||
<Loading withOverlay={false} small />
|
<Loading withOverlay={false} small />
|
|
@ -1,26 +1,23 @@
|
||||||
---
|
|
||||||
components: ["LocalStorage"]
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `LocalStorage` component provides a reactive wrapper around the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). It's useful for persisting user preferences and application state across page reloads.
|
This utility component wraps the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and is useful for persisting ephemeral data (e.g., color theme) at the browser level.
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
See how the component maintains state across page reloads. Toggle the switch and refresh the page to see the persisted state.
|
In the example below, toggle the switch and reload the page. The updated theme should be persisted locally.
|
||||||
|
|
||||||
<FileSource src="/framed/LocalStorage/LocalStorage" />
|
<FileSource src="/framed/LocalStorage/LocalStorage" />
|
||||||
|
|
||||||
## Clear item, clear all
|
### Clear item, clear all
|
||||||
|
|
||||||
The component provides methods to manage stored data:
|
Use the `bind:this` directive to access the `clearItem` and `clearAll` methods.
|
||||||
|
|
||||||
- `clearItem`: Remove a specific key-value pair
|
Invoking `clearItem` will remove the persisted key value from the browser's local storage.
|
||||||
- `clearAll`: Remove all stored data
|
|
||||||
|
|
||||||
Use `bind:this` to access these methods. In this example, try toggling the switch, refreshing the page, then clearing the storage.
|
Invoking `clearAll` will remove all key values.
|
||||||
|
|
||||||
|
In the following example, toggle the switch and reload the page. Then, click the "Clear storage" button. Refresh the page; the theme should be reset to the untoggled state.
|
||||||
|
|
||||||
<FileSource src="/framed/LocalStorage/LocalStorageClear" />
|
<FileSource src="/framed/LocalStorage/LocalStorageClear" />
|
|
@ -2,78 +2,46 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Modal` component provides a focused dialog for user interactions, confirmations, or data entry. It supports various sizes, states, and customization options to create accessible and user-friendly modal experiences.
|
### Default (transactional)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a modal dialog with a header, content area, and footer by default.
|
|
||||||
|
|
||||||
Create a basic modal dialog with primary and secondary actions. This variant is ideal for confirming user actions or gathering input.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/Modal" />
|
<FileSource src="/framed/Modal/Modal" />
|
||||||
|
|
||||||
## Custom focus
|
### Danger modal
|
||||||
|
|
||||||
Control which element receives focus when the modal opens. Use `selectorPrimaryFocus` to specify the target element using CSS selectors.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalCustomFocus" />
|
|
||||||
|
|
||||||
## Danger modal
|
|
||||||
|
|
||||||
Display critical actions or destructive operations with the danger variant. This style emphasizes the severity of the action.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/DangerModal" />
|
<FileSource src="/framed/Modal/DangerModal" />
|
||||||
|
|
||||||
## Passive modal
|
### Passive modal
|
||||||
|
|
||||||
Create a non-interactive modal for displaying information. This variant lacks action buttons and focuses on content presentation.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/PassiveModal" />
|
<FileSource src="/framed/Modal/PassiveModal" />
|
||||||
|
|
||||||
## Has scrolling content
|
### Multiple modals
|
||||||
|
|
||||||
Enable vertical scrolling for modals with lengthy content. This ensures all content remains accessible while maintaining a reasonable modal height.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalScrollingContent" />
|
|
||||||
|
|
||||||
## Multiple modals
|
|
||||||
|
|
||||||
Stack multiple modals for complex workflows. Each modal maintains its own state and focus management.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalMultiple" />
|
<FileSource src="/framed/Modal/ModalMultiple" />
|
||||||
|
|
||||||
## Multiple secondary buttons
|
### Multiple secondary buttons
|
||||||
|
|
||||||
Add up to two secondary actions using the `secondaryButtons` prop. This provides more flexibility than the single `secondaryButtonText` option.
|
Use the `secondaryButtons` prop to render two secondary buttons for a "3-button modal". The prop is a 2-tuple type that supersedes `secondaryButtonText`.
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/3ButtonModal" />
|
<FileSource src="/framed/Modal/3ButtonModal" />
|
||||||
|
|
||||||
## Extra-small size
|
### Extra-small size
|
||||||
|
|
||||||
Use the extra-small size for compact notifications by setting `size` to `"xs"`. This is ideal for simple confirmations.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalExtraSmall" />
|
<FileSource src="/framed/Modal/ModalExtraSmall" />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size for simple confirmations by setting `size` to `"sm"`. This provides a more focused dialog.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalSmall" />
|
<FileSource src="/framed/Modal/ModalSmall" />
|
||||||
|
|
||||||
## Large size
|
### Large size
|
||||||
|
|
||||||
Use the large size for complex content by setting `size` to `"lg"`. This provides more space for detailed information.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalLarge" />
|
<FileSource src="/framed/Modal/ModalLarge" />
|
||||||
|
|
||||||
## Prevent close on outside click
|
### Prevent close on outside click
|
||||||
|
|
||||||
Disable closing the modal when clicking outside by setting `preventCloseOnClickOutside` to `true`. This is useful for transactional modals where explicit user action is required.
|
`preventCloseOnClickOutside` prevents the modal from being closed when clicking outside of an open modal. This prop is intended to be used for transactional modals.
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalPreventOutsideClick" />
|
<FileSource src="/framed/Modal/ModalPreventOutsideClick" />
|
||||||
|
|
||||||
## Button with icon
|
### Button with icon
|
||||||
|
|
||||||
Enhance modal buttons with icons for better visual context and clarity. This example shows how to add icons to modal actions.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Modal/ModalButtonWithIcon" />
|
<FileSource src="/framed/Modal/ModalButtonWithIcon" />
|
||||||
|
|
|
@ -3,15 +3,15 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `MultiSelect` component provides a dropdown interface for selecting multiple options using checkboxes. It supports filtering, custom formatting, and various states. Each item must have a unique `id` property for proper functionality.
|
`MultiSelect` is keyed for performance reasons.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
<div class="body-short-01">Every <code>items</code> object must have a unique "id" property.</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Create a basic multi-select dropdown with three contact methods. By default, items are ordered alphabetically.
|
By default, items will be ordered alphabetically based on the `item.text` value. To prevent this, see [#no-alphabetical-ordering](#no-alphabetical-ordering).
|
||||||
|
|
||||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -19,9 +19,50 @@ Create a basic multi-select dropdown with three contact methods. By default, ite
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Format item display text
|
### Custom slot
|
||||||
|
|
||||||
Format the display text of items using the `itemToString` prop. This example appends the item ID in parentheses.
|
Override the default slot to customize the display of each item. Access the item and index through the `let:` directive.
|
||||||
|
|
||||||
|
<FileSource src="/framed/MultiSelect/MultiSelectSlot" />
|
||||||
|
|
||||||
|
### No alphabetical ordering
|
||||||
|
|
||||||
|
To prevent alphabetical item ordering, pass an empty function to the `sortItem` prop.
|
||||||
|
|
||||||
|
<MultiSelect titleText="Contact" label="Select contact methods..."
|
||||||
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
{id: "1", text: "Email"},
|
||||||
|
{id: "2", text: "Fax"}]}"
|
||||||
|
sortItem="{() => {}}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Filterable
|
||||||
|
|
||||||
|
`$$restProps` are spread to the underlying input element.
|
||||||
|
|
||||||
|
<MultiSelect spellcheck="false" filterable titleText="Contact" placeholder="Filter contact methods..."
|
||||||
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
{id: "1", text: "Email"},
|
||||||
|
{id: "2", text: "Fax"}]}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Initial selected items
|
||||||
|
|
||||||
|
To select (or bind) items, pass an array of item ids to `selectedIds`.
|
||||||
|
|
||||||
|
<MultiSelect selectedIds="{["0", "1"]}" titleText="Contact" label="Select contact methods..."
|
||||||
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
{id: "1", text: "Email"},
|
||||||
|
{id: "2", text: "Fax"}]}"
|
||||||
|
/>
|
||||||
|
|
||||||
|
### Multiple multi-select dropdowns
|
||||||
|
|
||||||
|
<FileSource src="/framed/MultiSelect/MultipleMultiSelect" />
|
||||||
|
|
||||||
|
### Format item display text
|
||||||
|
|
||||||
|
Use the `itemToString` prop to format the display of individual items.
|
||||||
|
|
||||||
<MultiSelect itemToString={item => {
|
<MultiSelect itemToString={item => {
|
||||||
return item.text + ' (' + item.id +')'
|
return item.text + ' (' + item.id +')'
|
||||||
|
@ -32,83 +73,9 @@ Format the display text of items using the `itemToString` prop. This example app
|
||||||
sortItem="{() => {}}"
|
sortItem="{() => {}}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Custom slot
|
### Top direction
|
||||||
|
|
||||||
Override the default slot to customize item rendering. This example shows how to access and use the item and index values.
|
Set `direction` to `"top"` for the dropdown menu to appear above the input.
|
||||||
|
|
||||||
<FileSource src="/framed/MultiSelect/MultiSelectSlot" />
|
|
||||||
|
|
||||||
## No alphabetical ordering
|
|
||||||
|
|
||||||
Prevent automatic alphabetical ordering by passing a no-op function to `sortItem`. This maintains the original order of items.
|
|
||||||
|
|
||||||
<MultiSelect titleText="Contact" label="Select contact methods..."
|
|
||||||
items="{[{id: "0", text: "Slack"},
|
|
||||||
{id: "1", text: "Email"},
|
|
||||||
{id: "2", text: "Fax"}]}"
|
|
||||||
sortItem="{() => {}}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Filterable
|
|
||||||
|
|
||||||
Enable filtering by setting `filterable` to `true`. This example includes a placeholder text for the filter input.
|
|
||||||
|
|
||||||
<MultiSelect spellcheck="false" filterable titleText="Contact" placeholder="Filter contact methods..."
|
|
||||||
items="{[{id: "0", text: "Slack"},
|
|
||||||
{id: "1", text: "Email"},
|
|
||||||
{id: "2", text: "Fax"}]}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Initial selected items
|
|
||||||
|
|
||||||
Pre-select items by passing an array of item IDs to `selectedIds`. This example pre-selects Slack and Email.
|
|
||||||
|
|
||||||
<MultiSelect selectedIds="{["0", "1"]}" titleText="Contact" label="Select contact methods..."
|
|
||||||
items="{[{id: "0", text: "Slack"},
|
|
||||||
{id: "1", text: "Email"},
|
|
||||||
{id: "2", text: "Fax"}]}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Multiple multi-select dropdowns
|
|
||||||
|
|
||||||
This example demonstrates how to manage multiple dropdowns in a form with coordinated state.
|
|
||||||
|
|
||||||
<FileSource src="/framed/MultiSelect/MultipleMultiSelect" />
|
|
||||||
|
|
||||||
## Format checkbox values
|
|
||||||
|
|
||||||
Customize checkbox attributes using the `itemToInput` prop. This example sets a consistent name for all checkboxes.
|
|
||||||
|
|
||||||
Use the `itemToInput` prop to customize the user-selectable checkbox values.
|
|
||||||
This will also override the underlying hidden inputs used for form submission.
|
|
||||||
|
|
||||||
```js
|
|
||||||
itemToInput={(item) => {
|
|
||||||
return {
|
|
||||||
name: `Contact_${item.id}`,
|
|
||||||
value: item.id
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
```
|
|
||||||
|
|
||||||
The above function sets the `name` attribute to
|
|
||||||
`Contact_0` (respective to each item's `id`) for every hidden input that
|
|
||||||
renders, along with each respective item's `id` set to the `value` attribute.
|
|
||||||
|
|
||||||
<MultiSelect
|
|
||||||
itemToInput={(item) => ({name: 'contact', value: item.id})}
|
|
||||||
titleText="Contact"
|
|
||||||
label="Select contact methods..."
|
|
||||||
items="{[
|
|
||||||
{id: "0", text: "Slack"},
|
|
||||||
{id: "1", text: "Email"},
|
|
||||||
{id: "2", text: "Fax"}
|
|
||||||
]}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Top direction
|
|
||||||
|
|
||||||
Display the dropdown menu above the input by setting `direction` to `"top"`. This is useful when space below is limited.
|
|
||||||
|
|
||||||
<MultiSelect direction="top" titleText="Contact" label="Select contact methods..."
|
<MultiSelect direction="top" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -116,9 +83,7 @@ Display the dropdown menu above the input by setting `direction` to `"top"`. Thi
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Hide the label visually while maintaining accessibility by setting `hideLabel` to `true`. The label is still available to screen readers.
|
|
||||||
|
|
||||||
<MultiSelect titleText="Contact" label="Select contact methods..." hideLabel
|
<MultiSelect titleText="Contact" label="Select contact methods..." hideLabel
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -126,9 +91,7 @@ Hide the label visually while maintaining accessibility by setting `hideLabel` t
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for dark backgrounds by setting `light` to `true`. This provides better contrast in dark themes.
|
|
||||||
|
|
||||||
<MultiSelect light titleText="Contact" label="Select contact methods..."
|
<MultiSelect light titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -136,9 +99,7 @@ Use the light variant for dark backgrounds by setting `light` to `true`. This pr
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Inline variant
|
### Inline variant
|
||||||
|
|
||||||
Display the dropdown inline with other content by setting `type` to `"inline"`. This removes the background and border.
|
|
||||||
|
|
||||||
<MultiSelect type="inline" titleText="Contact" label="Select contact methods..."
|
<MultiSelect type="inline" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -146,9 +107,7 @@ Display the dropdown inline with other content by setting `type` to `"inline"`.
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Use the extra-large size for prominent selections by setting `size` to `"xl"`. This provides more visual emphasis.
|
|
||||||
|
|
||||||
<MultiSelect size="xl" titleText="Contact" label="Select contact methods..."
|
<MultiSelect size="xl" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -156,9 +115,7 @@ Use the extra-large size for prominent selections by setting `size` to `"xl"`. T
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size for compact layouts by setting `size` to `"sm"`. This is ideal for secondary selections.
|
|
||||||
|
|
||||||
<MultiSelect size="sm" titleText="Contact" label="Select contact methods..."
|
<MultiSelect size="sm" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -166,9 +123,7 @@ Use the small size for compact layouts by setting `size` to `"sm"`. This is idea
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Indicate an invalid selection by setting `invalid` to `true`. This example shows a required field error.
|
|
||||||
|
|
||||||
<MultiSelect invalid invalidText="A contact method is required" titleText="Contact" label="Select contact methods..."
|
<MultiSelect invalid invalidText="A contact method is required" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -176,9 +131,7 @@ Indicate an invalid selection by setting `invalid` to `true`. This example shows
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Indicate a warning state by setting `warn` to `true`. This example shows a warning about unassociated accounts.
|
|
||||||
|
|
||||||
<MultiSelect warn warnText="One or more contact methods are not associated with your account" titleText="Contact" label="Select contact methods..."
|
<MultiSelect warn warnText="One or more contact methods are not associated with your account" titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
|
@ -186,26 +139,10 @@ Indicate a warning state by setting `warn` to `true`. This example shows a warni
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the entire dropdown by setting `disabled` to `true`. This prevents all user interaction.
|
|
||||||
|
|
||||||
<MultiSelect disabled titleText="Contact" label="Select contact methods..."
|
<MultiSelect disabled titleText="Contact" label="Select contact methods..."
|
||||||
items="{[{id: "0", text: "Slack"},
|
items="{[{id: "0", text: "Slack"},
|
||||||
{id: "1", text: "Email"},
|
{id: "1", text: "Email"},
|
||||||
{id: "2", text: "Fax"}]}"
|
{id: "2", text: "Fax"}]}"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
## Disabled items
|
|
||||||
|
|
||||||
Disable specific items using the `disabled` property in the `items` prop. This example disables the Email option.
|
|
||||||
|
|
||||||
<MultiSelect
|
|
||||||
titleText="Contact"
|
|
||||||
label="Select contact methods..."
|
|
||||||
items={[
|
|
||||||
{ id: "0", text: "Slack" },
|
|
||||||
{ id: "1", text: "Email", disabled: true },
|
|
||||||
{ id: "2", text: "Fax" },
|
|
||||||
]}
|
|
||||||
/>
|
|
||||||
|
|
|
@ -7,100 +7,70 @@ components: ["NumberInput", "NumberInputSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `NumberInput` component provides a controlled input for numerical values. It supports validation, step values, and various states to ensure accurate data entry.
|
### Default
|
||||||
|
|
||||||
## Default
|
This component requires a numerical value for `value`.
|
||||||
|
|
||||||
Create a basic number input with increment and decrement controls. The input accepts numerical values and provides visual feedback.
|
See [#no-value](#no-value) to allow for an empty value.
|
||||||
|
|
||||||
<NumberInput label="Clusters" value={0} />
|
<NumberInput label="Clusters" value={0} />
|
||||||
|
|
||||||
## No value
|
### With helper text
|
||||||
|
|
||||||
Allow empty values by setting both `allowEmpty` to `true` and `value` to `null`. The `allowEmpty` prop enables the empty state, while `value={null}` represents no value.
|
|
||||||
|
|
||||||
<FileSource src="/framed/NumberInput/NumberInputEmpty" />
|
|
||||||
|
|
||||||
## Helper text
|
|
||||||
|
|
||||||
Add descriptive text below the input using the `helperText` prop. This helps users understand the expected input.
|
|
||||||
|
|
||||||
<NumberInput label="Clusters" value={0} helperText="Clusters provisioned in your region" />
|
<NumberInput label="Clusters" value={0} helperText="Clusters provisioned in your region" />
|
||||||
|
|
||||||
## Minimum and maximum values
|
### Minimum and maximum values
|
||||||
|
|
||||||
Constrain input values using `min` and `max` props. This example limits values between 4 and 20.
|
|
||||||
|
|
||||||
<NumberInput min="{4}" max="{20}" value="{4}" invalidText="Number must be between 4 and 20." helperText="Clusters provisioned in your region" label="Clusters (4 min, 20 max)" />
|
<NumberInput min="{4}" max="{20}" value="{4}" invalidText="Number must be between 4 and 20." helperText="Clusters provisioned in your region" label="Clusters (4 min, 20 max)" />
|
||||||
|
|
||||||
## Step value
|
### No value
|
||||||
|
|
||||||
Control the increment/decrement step size using the `step` prop. This example uses a step of 0.1.
|
Set `allowEmpty` to `true` to allow for no value.
|
||||||
|
|
||||||
<NumberInput value="{1}" helperText="Step of 0.1" step={0.1} label="Clusters" />
|
Set `value` to `null` to denote "no value."
|
||||||
|
|
||||||
## Hidden label
|
<FileSource src="/framed/NumberInput/NumberInputEmpty" />
|
||||||
|
|
||||||
Hide the label visually while maintaining accessibility by setting `hideLabel` to `true`. The label is still available to screen readers.
|
### Hidden label
|
||||||
|
|
||||||
<NumberInput hideLabel label="Clusters" value={0} />
|
<NumberInput hideLabel label="Clusters" value={0} />
|
||||||
|
|
||||||
## Extra-large size
|
### Hidden steppers
|
||||||
|
|
||||||
Use the extra-large size for prominent inputs by setting `size` to `"xl"`. This provides more visual emphasis.
|
|
||||||
|
|
||||||
<NumberInput size="xl" label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Small size
|
|
||||||
|
|
||||||
Use the small size for compact layouts by setting `size` to `"sm"`. This is ideal for secondary inputs.
|
|
||||||
|
|
||||||
<NumberInput size="sm" label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Light variant
|
|
||||||
|
|
||||||
Use the light variant for dark backgrounds by setting `light` to `true`. This provides better contrast in dark themes.
|
|
||||||
|
|
||||||
<NumberInput light label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Invalid state
|
|
||||||
|
|
||||||
Indicate an invalid value by setting `invalid` to `true`. This example shows a validation error.
|
|
||||||
|
|
||||||
<NumberInput invalid invalidText="Invalid value" label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Warning state
|
|
||||||
|
|
||||||
Indicate a warning state by setting `warn` to `true`. This example shows a warning about the input value.
|
|
||||||
|
|
||||||
<NumberInput warn warnText="A high number may impact initial rollout" label="Clusters" value={25} />
|
|
||||||
|
|
||||||
## Disabled state
|
|
||||||
|
|
||||||
Disable the input by setting `disabled` to `true`. This prevents all user interaction.
|
|
||||||
|
|
||||||
<NumberInput disabled label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Read-only state
|
|
||||||
|
|
||||||
Make the input read-only by setting `readonly` to `true`. This allows viewing but prevents editing.
|
|
||||||
|
|
||||||
<NumberInput readonly label="Clusters" value={0} />
|
|
||||||
|
|
||||||
## Hidden steppers
|
|
||||||
|
|
||||||
Hide the increment/decrement controls by setting `hideSteppers` to `true`. This provides a simpler input interface.
|
|
||||||
|
|
||||||
<NumberInput hideSteppers label="Clusters" value={0} />
|
<NumberInput hideSteppers label="Clusters" value={0} />
|
||||||
|
|
||||||
## Skeleton
|
### Light variant
|
||||||
|
|
||||||
Show a loading state using the `NumberInputSkeleton` component. This is useful while data is being fetched.
|
<NumberInput light label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Read-only variant
|
||||||
|
|
||||||
|
<NumberInput readonly label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Extra-large size
|
||||||
|
|
||||||
|
<NumberInput size="xl" label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Small size
|
||||||
|
|
||||||
|
<NumberInput size="sm" label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Invalid state
|
||||||
|
|
||||||
|
<NumberInput invalid invalidText="Invalid value" label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Warning state
|
||||||
|
|
||||||
|
<NumberInput warn warnText="A high number may impact initial rollout" label="Clusters" value={25} />
|
||||||
|
|
||||||
|
### Disabled state
|
||||||
|
|
||||||
|
<NumberInput disabled label="Clusters" value={0} />
|
||||||
|
|
||||||
|
### Skeleton
|
||||||
|
|
||||||
<NumberInputSkeleton />
|
<NumberInputSkeleton />
|
||||||
|
|
||||||
## Skeleton without label
|
### Skeleton without label
|
||||||
|
|
||||||
Show a loading state without a label by setting `hideLabel` to `true`. This maintains layout consistency.
|
|
||||||
|
|
||||||
<NumberInputSkeleton hideLabel />
|
<NumberInputSkeleton hideLabel />
|
|
@ -7,17 +7,13 @@ components: ["OrderedList", "ListItem"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`OrderedList` provides a structured way to display numbered lists of items. It supports nested lists, native browser styles, and expressive typography for enhanced visual hierarchy.
|
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Tip:" kind="info" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Tip:" kind="info" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
Consider using the <Link href="/components/RecursiveList#ordered">RecursiveList</Link> component for rendering tree structured data.
|
Consider using the <Link href="/components/RecursiveList#ordered">RecursiveList</Link> component for rendering tree structured data.
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
### Default
|
||||||
|
|
||||||
Create a basic ordered list by wrapping `ListItem` components within `OrderedList`.
|
|
||||||
|
|
||||||
<OrderedList>
|
<OrderedList>
|
||||||
<ListItem>Ordered list item</ListItem>
|
<ListItem>Ordered list item</ListItem>
|
||||||
|
@ -25,9 +21,7 @@ Create a basic ordered list by wrapping `ListItem` components within `OrderedLis
|
||||||
<ListItem>Ordered list item</ListItem>
|
<ListItem>Ordered list item</ListItem>
|
||||||
</OrderedList>
|
</OrderedList>
|
||||||
|
|
||||||
## With links
|
### With links
|
||||||
|
|
||||||
Add interactive elements like `Link` components within list items.
|
|
||||||
|
|
||||||
<OrderedList>
|
<OrderedList>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
|
@ -41,9 +35,7 @@ Add interactive elements like `Link` components within list items.
|
||||||
</ListItem>
|
</ListItem>
|
||||||
</OrderedList>
|
</OrderedList>
|
||||||
|
|
||||||
## Nested
|
### Nested
|
||||||
|
|
||||||
Set the `nested` prop to `true` to create hierarchical lists with proper indentation and numbering.
|
|
||||||
|
|
||||||
<OrderedList>
|
<OrderedList>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
|
@ -63,9 +55,9 @@ Set the `nested` prop to `true` to create hierarchical lists with proper indenta
|
||||||
<ListItem>Ordered list level 1</ListItem>
|
<ListItem>Ordered list level 1</ListItem>
|
||||||
</OrderedList>
|
</OrderedList>
|
||||||
|
|
||||||
## Native list styles
|
### Native list styles
|
||||||
|
|
||||||
Enable native browser list styles by setting the `native` prop to `true`. This is useful for large lists where the list number may overlap with the list item text.
|
Use the `native` attribute to enable default browser list styles. This is useful for large lists (i.e., 1000 or more items) where the list number may overlap with the list item text.
|
||||||
|
|
||||||
<OrderedList native>
|
<OrderedList native>
|
||||||
<ListItem>
|
<ListItem>
|
||||||
|
@ -85,9 +77,9 @@ Enable native browser list styles by setting the `native` prop to `true`. This i
|
||||||
<ListItem>Ordered list level 1</ListItem>
|
<ListItem>Ordered list level 1</ListItem>
|
||||||
</OrderedList>
|
</OrderedList>
|
||||||
|
|
||||||
## Expressive styles
|
### Expressive styles
|
||||||
|
|
||||||
Use Carbon's expressive typesetting by setting the `expressive` prop to `true`.
|
Set `expressive` to `true` to use Carbon's expressive typesetting.
|
||||||
|
|
||||||
<OrderedList expressive>
|
<OrderedList expressive>
|
||||||
<ListItem><Link size="lg" href="#">Ordered list item</Link></ListItem>
|
<ListItem><Link size="lg" href="#">Ordered list item</Link></ListItem>
|
||||||
|
|
|
@ -8,11 +8,7 @@ components: ["OverflowMenu", "OverflowMenuItem"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`OverflowMenu` provides a compact way to display a list of actions or options. It renders as a button that opens a dropdown menu when clicked, making it ideal for secondary actions or overflow content.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic overflow menu by wrapping `OverflowMenuItem` components within `OverflowMenu`.
|
|
||||||
|
|
||||||
<OverflowMenu>
|
<OverflowMenu>
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -20,19 +16,15 @@ Create a basic overflow menu by wrapping `OverflowMenuItem` components within `O
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Flipped
|
### Flipped
|
||||||
|
|
||||||
Set `flipped` to `true` to position the menu to the left of the button.
|
<OverflowMenu open flipped>
|
||||||
|
|
||||||
<OverflowMenu flipped>
|
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
<OverflowMenuItem href="https://cloud.ibm.com/docs/api-gateway/" text="API documentation" />
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Menu direction
|
### Menu direction top
|
||||||
|
|
||||||
Set `direction` to `"top"` to position the menu above the button.
|
|
||||||
|
|
||||||
<OverflowMenu flipped direction="top">
|
<OverflowMenu flipped direction="top">
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -40,9 +32,7 @@ Set `direction` to `"top"` to position the menu above the button.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Enable the light variant by setting `light` to `true`.
|
|
||||||
|
|
||||||
<OverflowMenu light>
|
<OverflowMenu light>
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -50,9 +40,7 @@ Enable the light variant by setting `light` to `true`.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Set `size` to `"xl"` for an extra-large overflow menu.
|
|
||||||
|
|
||||||
<OverflowMenu size="xl">
|
<OverflowMenu size="xl">
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -60,9 +48,7 @@ Set `size` to `"xl"` for an extra-large overflow menu.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Set `size` to `"sm"` for a small overflow menu.
|
|
||||||
|
|
||||||
<OverflowMenu size="sm">
|
<OverflowMenu size="sm">
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -70,9 +56,9 @@ Set `size` to `"sm"` for a small overflow menu.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Custom primary focus
|
### Custom primary focus
|
||||||
|
|
||||||
Set `primaryFocus` to `true` on a menu item to focus it when opening the dropdown.
|
By default, the first overflow menu item is focused when opening the dropdown.
|
||||||
|
|
||||||
<OverflowMenu>
|
<OverflowMenu>
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -80,9 +66,7 @@ Set `primaryFocus` to `true` on a menu item to focus it when opening the dropdow
|
||||||
<OverflowMenuItem primaryFocus danger text="Delete service" />
|
<OverflowMenuItem primaryFocus danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Custom trigger icon
|
### Custom trigger icon
|
||||||
|
|
||||||
Replace the default vertical overflow menu icon with a custom icon.
|
|
||||||
|
|
||||||
<OverflowMenu icon={Add}>
|
<OverflowMenu icon={Add}>
|
||||||
<OverflowMenuItem text="Manage credentials" />
|
<OverflowMenuItem text="Manage credentials" />
|
||||||
|
@ -90,9 +74,7 @@ Replace the default vertical overflow menu icon with a custom icon.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Custom trigger slot
|
### Custom trigger slot
|
||||||
|
|
||||||
Use the `menu` slot to customize the trigger button content.
|
|
||||||
|
|
||||||
<OverflowMenu style="width: auto;">
|
<OverflowMenu style="width: auto;">
|
||||||
<div slot="menu" style="padding: 1rem; color: red;">Custom trigger</div>
|
<div slot="menu" style="padding: 1rem; color: red;">Custom trigger</div>
|
||||||
|
@ -101,9 +83,9 @@ Use the `menu` slot to customize the trigger button content.
|
||||||
<OverflowMenuItem danger text="Delete service" />
|
<OverflowMenuItem danger text="Delete service" />
|
||||||
</OverflowMenu>
|
</OverflowMenu>
|
||||||
|
|
||||||
## Disabled items
|
### Disabled items
|
||||||
|
|
||||||
Set `disabled` to `true` to disable menu items. Use `hasDivider` to add visual separation between items.
|
Disable menu items by setting `disabled` to `true`.
|
||||||
|
|
||||||
<OverflowMenu>
|
<OverflowMenu>
|
||||||
<OverflowMenuItem text="Create key" />
|
<OverflowMenuItem text="Create key" />
|
||||||
|
|
|
@ -7,52 +7,26 @@ components: ["Pagination", "PaginationSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Pagination` provides navigation controls for large data sets. It displays the current page, total items, and allows users to change page size and navigate between pages.
|
### Default
|
||||||
|
|
||||||
## Default
|
<Pagination totalItems={102} pageSizes="{[10, 15, 20]}" />
|
||||||
|
|
||||||
Create a basic pagination component with default page size options.
|
### Current page
|
||||||
|
|
||||||
<Pagination totalItems={102} pageSizes={[10, 15, 20]} />
|
|
||||||
|
|
||||||
## Current page
|
|
||||||
|
|
||||||
Set the current page using the `page` prop.
|
|
||||||
|
|
||||||
<Pagination totalItems={102} page={4} />
|
<Pagination totalItems={102} page={4} />
|
||||||
|
|
||||||
## Custom page sizes
|
### Custom page sizes
|
||||||
|
|
||||||
Specify custom page sizes and set a default page size.
|
<Pagination totalItems={102} pageSizes="{[16, 36, 99]}" pageSize="{36}" />
|
||||||
|
|
||||||
<Pagination totalItems={102} pageSizes={[16, 36, 99]} pageSize={36} />
|
### Hidden page input
|
||||||
|
|
||||||
## Unknown pages
|
|
||||||
|
|
||||||
Set `pagesUnknown` to `true` when the total number of pages is unknown. This renders the item range text without factoring in the total number of pages.
|
|
||||||
|
|
||||||
<Pagination pagesUnknown />
|
|
||||||
|
|
||||||
## Page window
|
|
||||||
|
|
||||||
The number of native select items rendered is derived from `totalItems`. For large datasets, this can impact performance. Use `pageWindow` to control the number of rendered items.
|
|
||||||
|
|
||||||
<Pagination totalItems={100_000} pageSizes={[10, 15, 20]} />
|
|
||||||
|
|
||||||
## Hidden page input
|
|
||||||
|
|
||||||
Disable the page input by setting `pageInputDisabled` to `true`.
|
|
||||||
|
|
||||||
<Pagination totalItems={102} pageInputDisabled />
|
<Pagination totalItems={102} pageInputDisabled />
|
||||||
|
|
||||||
## Hidden page size
|
### Hidden page size
|
||||||
|
|
||||||
Disable the page size selector by setting `pageSizeInputDisabled` to `true`.
|
|
||||||
|
|
||||||
<Pagination totalItems={102} pageSizeInputDisabled />
|
<Pagination totalItems={102} pageSizeInputDisabled />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Use `PaginationSkeleton` to show a loading state.
|
|
||||||
|
|
||||||
<PaginationSkeleton />
|
<PaginationSkeleton />
|
||||||
|
|
|
@ -3,49 +3,10 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`PaginationNav` provides a compact navigation interface for paginated content. It displays page numbers and navigation buttons, with support for overflow menus when there are many pages.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic pagination navigation with default settings.
|
|
||||||
|
|
||||||
<PaginationNav />
|
<PaginationNav />
|
||||||
|
|
||||||
## Reactive example
|
### Loopable
|
||||||
|
|
||||||
Use the `page` prop to bind to the current page number.
|
|
||||||
|
|
||||||
<FileSource src="/framed/PaginationNav/PaginationNavReactive" />
|
|
||||||
|
|
||||||
## Total pages
|
|
||||||
|
|
||||||
Specify the total number of pages using the `total` prop.
|
|
||||||
|
|
||||||
<PaginationNav total={3} />
|
|
||||||
|
|
||||||
## Loop navigation
|
|
||||||
|
|
||||||
Set `loop` to `true` to enable circular navigation between pages.
|
|
||||||
|
|
||||||
<PaginationNav total={3} loop />
|
<PaginationNav total={3} loop />
|
||||||
|
|
||||||
## Visible pages
|
|
||||||
|
|
||||||
Control the number of visible page numbers with the `shown` prop.
|
|
||||||
|
|
||||||
<PaginationNav total={100} shown={5} />
|
|
||||||
|
|
||||||
## Custom button text
|
|
||||||
|
|
||||||
Customize the navigation button text using `forwardText` and `backwardText`.
|
|
||||||
|
|
||||||
<PaginationNav
|
|
||||||
forwardText="Next"
|
|
||||||
backwardText="Previous"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Tooltip position
|
|
||||||
|
|
||||||
Set the tooltip position relative to the navigation buttons using `tooltipPosition`.
|
|
||||||
|
|
||||||
<PaginationNav tooltipPosition="outside" total={3} loop />
|
|
|
@ -1,78 +1,56 @@
|
||||||
|
---
|
||||||
|
source: TextInput/PasswordInput.svelte
|
||||||
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { PasswordInput } from "carbon-components-svelte";
|
import { PasswordInput } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`PasswordInput` provides a secure text input field with a visibility toggle for password entry. It includes features for validation, warnings, and accessibility.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic password input with a label and placeholder.
|
|
||||||
|
|
||||||
<PasswordInput labelText="Password" placeholder="Enter password..." />
|
<PasswordInput labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Custom tooltip alignment
|
### Custom tooltip alignment
|
||||||
|
|
||||||
Customize the tooltip alignment and position of the visibility toggle through the `tooltipAlignment` and `tooltipPosition` props.
|
Customize the tooltip alignment and position of the visibility toggle through the `tooltipAlignment` and `tooltipPosition` props.
|
||||||
|
|
||||||
<PasswordInput tooltipAlignment="start" tooltipPosition="left" labelText="Password" placeholder="Enter password..." />
|
<PasswordInput tooltipAlignment="start" tooltipPosition="left" labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Password is visible
|
### Password is visible
|
||||||
|
|
||||||
Set prop `type` to `"text"` to toggle password visibility.
|
Set prop `type` to `"text"` to toggle password visibility.
|
||||||
|
|
||||||
<PasswordInput labelText="Password" type="text" placeholder="Enter password..." value="as_lta0890sdfpo__!9901" />
|
<PasswordInput labelText="Password" type="text" placeholder="Enter password..." value="as_lta0890sdfpo__!9901" />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility.
|
|
||||||
|
|
||||||
<PasswordInput hideLabel labelText="Password" placeholder="Enter password..." />
|
<PasswordInput hideLabel labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Enable the light variant for use on dark backgrounds.
|
|
||||||
|
|
||||||
<PasswordInput light labelText="Password" placeholder="Enter password..." />
|
<PasswordInput light labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Inline
|
### Inline
|
||||||
|
|
||||||
Display the input with an inline label layout.
|
|
||||||
|
|
||||||
<PasswordInput inline labelText="Password" placeholder="Enter password..." />
|
<PasswordInput inline labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Use the extra-large size variant for increased visibility.
|
|
||||||
|
|
||||||
<PasswordInput size="xl" labelText="Password" placeholder="Enter password..." />
|
<PasswordInput size="xl" labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size variant for compact layouts.
|
|
||||||
|
|
||||||
<PasswordInput size="sm" labelText="Password" placeholder="Enter password..." />
|
<PasswordInput size="sm" labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Display an error message when the input is invalid.
|
|
||||||
|
|
||||||
<PasswordInput invalid invalidText="Incorrect user name or password." labelText="Password" placeholder="Enter password..." />
|
<PasswordInput invalid invalidText="Incorrect user name or password." labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Show a warning message for non-critical issues.
|
|
||||||
|
|
||||||
<PasswordInput warn warnText="Password has been reset." labelText="Password" placeholder="Enter password..." />
|
<PasswordInput warn warnText="Password has been reset." labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the input to prevent user interaction.
|
|
||||||
|
|
||||||
<PasswordInput disabled labelText="Password" placeholder="Enter password..." />
|
<PasswordInput disabled labelText="Password" placeholder="Enter password..." />
|
||||||
|
|
||||||
## With helper text
|
|
||||||
|
|
||||||
Add helper text to provide additional context or instructions.
|
|
||||||
|
|
||||||
<PasswordInput helperText="Your password should be hard to guess" labelText="Password" placeholder="Enter password..." />
|
|
||||||
|
|
|
@ -3,11 +3,9 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Popover` provides a floating container that displays content relative to a trigger element. It supports various alignments, caret indicators, and visual variants.
|
### Default
|
||||||
|
|
||||||
## Default
|
By default, the position of the popover component is absolute.
|
||||||
|
|
||||||
Create a basic popover with absolute positioning.
|
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -16,9 +14,9 @@ Create a basic popover with absolute positioning.
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Relative position
|
### Relative position
|
||||||
|
|
||||||
Set `relative` to `true` to position the popover relative to its parent element.
|
Set `relative` to `true` to use a relative position.
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -27,9 +25,9 @@ Set `relative` to `true` to position the popover relative to its parent element.
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Close on outside click
|
### Close on outside click
|
||||||
|
|
||||||
Enable automatic closing when clicking outside the popover using `closeOnOutsideClick`.
|
Set `closeOnOutsideClick` to set `open` to `false` when clicking outside of the popover.
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -38,7 +36,7 @@ Enable automatic closing when clicking outside the popover using `closeOnOutside
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Popover alignment
|
### Popover alignment
|
||||||
|
|
||||||
Customize the popover alignment using the `align` prop. Valid values include: `"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"`.
|
Customize the popover alignment using the `align` prop. Valid values include: `"top" | "top-left" | "top-right" | "bottom" | "bottom-left" | "bottom-right" | "left" | "left-bottom" | "left-top" | "right" | "right-bottom" | "right-top"`.
|
||||||
|
|
||||||
|
@ -111,9 +109,7 @@ The default `align` value is `"top"`.
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## With caret
|
### With caret
|
||||||
|
|
||||||
Add a caret indicator to the popover using the `caret` prop.
|
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -122,9 +118,11 @@ Add a caret indicator to the popover using the `caret` prop.
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Custom caret alignment
|
### Custom caret alignment
|
||||||
|
|
||||||
By default, the caret is aligned "top". Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`, `"bottom-right"`, `"left"`, `"left-bottom"`, `"left-top"`, `"right"`, `"right-bottom"` or `"right-top"`.
|
By default, the caret is aligned "top".
|
||||||
|
|
||||||
|
Possible `align` values include `"top"`, `"top-left"`, `"top-right"`, `"bottom"`, `"bottom-left"`, `"bottom-right"`, `"left"`, `"left-bottom"`, `"left-top"`, `"right"`, `"right-bottom"` or `"right-top"`.
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -133,9 +131,7 @@ By default, the caret is aligned "top". Possible `align` values include `"top"`,
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Enable the light variant for use on dark backgrounds.
|
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -144,9 +140,7 @@ Enable the light variant for use on dark backgrounds.
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## High contrast variant
|
### High contrast variant
|
||||||
|
|
||||||
Enable the high contrast variant for improved visibility.
|
|
||||||
|
|
||||||
<div data-outline>
|
<div data-outline>
|
||||||
Parent
|
Parent
|
||||||
|
@ -154,9 +148,3 @@ Enable the high contrast variant for improved visibility.
|
||||||
<div style="padding: var(--cds-spacing-05)">Content</div>
|
<div style="padding: var(--cds-spacing-05)">Content</div>
|
||||||
</Popover>
|
</Popover>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## External element
|
|
||||||
|
|
||||||
Use the `open` prop to manage state with an external element, like a button.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Popover/WithButton" />
|
|
|
@ -3,70 +3,50 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ProgressBar` provides a visual indicator of progress for operations such as file uploads or data processing. It supports determinate and indeterminate states, various sizes, and status indicators.
|
### Default
|
||||||
|
|
||||||
## Default
|
Without a specified `value` prop, the progress bar is indeterminate.
|
||||||
|
|
||||||
Create an indeterminate progress bar that continuously animates.
|
|
||||||
|
|
||||||
<ProgressBar helperText="Loading..." />
|
<ProgressBar helperText="Loading..." />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size variant for compact layouts.
|
Specify `size="sm"` to use the small variant.
|
||||||
|
|
||||||
<ProgressBar size="sm" helperText="Loading..." />
|
<ProgressBar size="sm" helperText="Loading..." />
|
||||||
|
|
||||||
## Percentage
|
### Percentage
|
||||||
|
|
||||||
Display progress as a percentage using the `value` prop.
|
Specify a `value` for the progress bar to be determinate.
|
||||||
|
|
||||||
<ProgressBar value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
<ProgressBar value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||||
|
|
||||||
## Finished status
|
### Custom max value
|
||||||
|
|
||||||
Show completion status with a checkmark icon.
|
The default `max` value is `100`.
|
||||||
|
|
||||||
<ProgressBar value={100} status="finished" labelText="Upload file" helperText="Upload complete" />
|
|
||||||
|
|
||||||
## Error status
|
|
||||||
|
|
||||||
Indicate errors with an error icon and red styling.
|
|
||||||
|
|
||||||
<ProgressBar value={0} status="error" labelText="Upload file" helperText="Invalid file format" />
|
|
||||||
|
|
||||||
## Custom max value
|
|
||||||
|
|
||||||
Set a custom maximum value for the progress bar.
|
|
||||||
|
|
||||||
<ProgressBar value={40} max={200} labelText="Upload status" helperText="40 MB of 200 MB" />
|
<ProgressBar value={40} max={200} labelText="Upload status" helperText="40 MB of 200 MB" />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility.
|
It's recommended that you provide a `labelText` for accessibility.
|
||||||
|
|
||||||
|
Use `hideLabel` to visually hide the label text.
|
||||||
|
|
||||||
<ProgressBar hideLabel value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
<ProgressBar hideLabel value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||||
|
|
||||||
## Inline variant
|
### Inline variant
|
||||||
|
|
||||||
Use the inline variant to display progress without helper text.
|
The inline variant visually hides the `helperText`.
|
||||||
|
|
||||||
<ProgressBar kind="inline" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
<ProgressBar kind="inline" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||||
|
|
||||||
## Indented variant
|
### Indented variant
|
||||||
|
|
||||||
Use the indented variant for a more compact layout.
|
|
||||||
|
|
||||||
<ProgressBar kind="indented" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
<ProgressBar kind="indented" value={40} labelText="Upload status" helperText="40 MB of 100 MB" />
|
||||||
|
|
||||||
## Indented status variant
|
### UX example
|
||||||
|
|
||||||
Combine the indented variant with status indicators.
|
This example shows how to animate the progress bar from 0 to 100% with start and end states.
|
||||||
|
|
||||||
<ProgressBar kind="indented" status="finished" value={40} labelText="Upload file" helperText="Upload complete" />
|
|
||||||
|
|
||||||
## UX example
|
|
||||||
|
|
||||||
Demonstrate a complete upload flow with start and end states.
|
|
||||||
|
|
||||||
<FileSource src="/framed/ProgressBar/ProgressBarUx" />
|
<FileSource src="/framed/ProgressBar/ProgressBarUx" />
|
|
@ -7,11 +7,7 @@ components: ["ProgressIndicator", "ProgressStep", "ProgressIndicatorSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ProgressIndicator` provides a visual representation of progress through a sequence of steps. It supports horizontal and vertical layouts, step completion states, and interactive navigation.
|
### Default (horizontal)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a horizontal progress indicator with four steps.
|
|
||||||
|
|
||||||
<ProgressIndicator currentIndex={2}>
|
<ProgressIndicator currentIndex={2}>
|
||||||
<ProgressStep complete
|
<ProgressStep complete
|
||||||
|
@ -32,9 +28,11 @@ Create a horizontal progress indicator with four steps.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Prevent change on click
|
### Prevent change on click
|
||||||
|
|
||||||
Disable automatic step selection when clicking completed steps.
|
By default, clicking any step that is complete will update the current step index.
|
||||||
|
|
||||||
|
Set `preventChangeOnClick` to `true` to prevent this behavior.
|
||||||
|
|
||||||
<ProgressIndicator preventChangeOnClick currentIndex={2}>
|
<ProgressIndicator preventChangeOnClick currentIndex={2}>
|
||||||
<ProgressStep complete
|
<ProgressStep complete
|
||||||
|
@ -55,15 +53,13 @@ Disable automatic step selection when clicking completed steps.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Programmatic usage
|
### Programmatic usage
|
||||||
|
|
||||||
Update the current step programmatically while maintaining step completion rules.
|
When programmatically updating the `currentIndex`, keep in mind that only completed steps should be selectable.
|
||||||
|
|
||||||
<FileSource src="/framed/ProgressIndicator/ProgrammaticProgressIndicator" />
|
<FileSource src="/framed/ProgressIndicator/ProgrammaticProgressIndicator" />
|
||||||
|
|
||||||
## Invalid step
|
### Invalid step
|
||||||
|
|
||||||
Mark a step as invalid to indicate an error state.
|
|
||||||
|
|
||||||
<ProgressIndicator>
|
<ProgressIndicator>
|
||||||
<ProgressStep complete
|
<ProgressStep complete
|
||||||
|
@ -80,9 +76,7 @@ Mark a step as invalid to indicate an error state.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Disabled steps
|
### Disabled steps
|
||||||
|
|
||||||
Disable specific steps to prevent user interaction.
|
|
||||||
|
|
||||||
<ProgressIndicator>
|
<ProgressIndicator>
|
||||||
<ProgressStep complete
|
<ProgressStep complete
|
||||||
|
@ -99,9 +93,7 @@ Disable specific steps to prevent user interaction.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Spaced-equally
|
### Spaced-equally
|
||||||
|
|
||||||
Distribute steps evenly across the available space.
|
|
||||||
|
|
||||||
<ProgressIndicator spaceEqually>
|
<ProgressIndicator spaceEqually>
|
||||||
<ProgressStep
|
<ProgressStep
|
||||||
|
@ -118,9 +110,7 @@ Distribute steps evenly across the available space.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Vertical
|
### Vertical
|
||||||
|
|
||||||
Display steps in a vertical layout.
|
|
||||||
|
|
||||||
<ProgressIndicator vertical>
|
<ProgressIndicator vertical>
|
||||||
<ProgressStep
|
<ProgressStep
|
||||||
|
@ -137,14 +127,12 @@ Display steps in a vertical layout.
|
||||||
/>
|
/>
|
||||||
</ProgressIndicator>
|
</ProgressIndicator>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Show a loading state with the specified number of steps.
|
Use the `count` prop to specify the number of progress steps to render.
|
||||||
|
|
||||||
<ProgressIndicatorSkeleton />
|
<ProgressIndicatorSkeleton />
|
||||||
|
|
||||||
## Skeleton (vertical)
|
### Skeleton (vertical)
|
||||||
|
|
||||||
Show a vertical loading state with the specified number of steps.
|
|
||||||
|
|
||||||
<ProgressIndicatorSkeleton vertical />
|
<ProgressIndicatorSkeleton vertical />
|
|
@ -7,34 +7,28 @@ components: ["RadioButtonGroup", "RadioButton", "RadioButtonSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`RadioButton` provides a selection control that allows users to choose a single option from a set. It supports both individual and grouped usage, with options for horizontal and vertical layouts.
|
### Default
|
||||||
|
|
||||||
## Default
|
<RadioButtonGroup selected="standard">
|
||||||
|
|
||||||
Create a group of radio buttons with a shared name and legend.
|
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Storage tier (disk)" name="plan" selected="standard">
|
|
||||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Hidden legend
|
### With legend text
|
||||||
|
|
||||||
Visually hide the legend while maintaining accessibility.
|
<RadioButtonGroup legendText="Storage tier (disk)" selected="standard">
|
||||||
|
|
||||||
<RadioButtonGroup hideLegend legendText="Storage tier (disk)" name="plan-legend" selected="standard">
|
|
||||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Legend text slot
|
### Legend text slot
|
||||||
|
|
||||||
Customize the legend text with additional content.
|
Use the named "legendText" slot to customize the legend text.
|
||||||
|
|
||||||
<RadioButtonGroup name="plan-legend-slot" selected="standard">
|
<RadioButtonGroup selected="standard">
|
||||||
<div slot="legendText" style:display="flex">
|
<div slot="legendText" style="display: flex">
|
||||||
Storage tier (disk)
|
Storage tier (disk)
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<p>
|
<p>
|
||||||
|
@ -47,45 +41,49 @@ Customize the legend text with additional content.
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Reactive example
|
### Hidden legend
|
||||||
|
|
||||||
Bind and update the selected value programmatically.
|
It's recommended that you provide a legend for accessibility.
|
||||||
|
|
||||||
<FileSource src="/framed/RadioButton/RadioButtonReactive" />
|
Use `hideLegend` to visually hide the legend text.
|
||||||
|
|
||||||
## Left-aligned label text
|
<RadioButtonGroup hideLegend legendText="Storage tier (disk)" selected="standard">
|
||||||
|
|
||||||
Position labels to the left of the radio buttons.
|
|
||||||
|
|
||||||
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" name="plan-left-aligned" selected="standard">
|
|
||||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Disabled buttons
|
### Reactive example
|
||||||
|
|
||||||
Disable specific radio buttons to prevent selection.
|
Use the `selected` prop to bind and update the selected value.
|
||||||
|
|
||||||
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" name="plan-disabled" selected="standard">
|
<FileSource src="/framed/RadioButton/RadioButtonReactive" />
|
||||||
|
|
||||||
|
### Left-aligned label text
|
||||||
|
|
||||||
|
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" selected="standard">
|
||||||
|
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||||
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
|
</RadioButtonGroup>
|
||||||
|
|
||||||
|
### Disabled buttons
|
||||||
|
|
||||||
|
<RadioButtonGroup labelPosition="left" legendText="Storage tier (disk)" selected="standard">
|
||||||
<RadioButton disabled labelText="Free (1 GB)" value="free" />
|
<RadioButton disabled labelText="Free (1 GB)" value="free" />
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
<RadioButton disabled labelText="Pro (128 GB)" value="pro" />
|
<RadioButton disabled labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Vertical orientation
|
### Vertical orientation
|
||||||
|
|
||||||
Display radio buttons in a vertical layout.
|
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)" selected="standard">
|
||||||
|
|
||||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)" name="plan-vertical" selected="standard">
|
|
||||||
<RadioButton labelText="Free (1 GB)" value="free" />
|
<RadioButton labelText="Free (1 GB)" value="free" />
|
||||||
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
<RadioButton labelText="Standard (10 GB)" value="standard" />
|
||||||
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
<RadioButton labelText="Pro (128 GB)" value="pro" />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Show a loading state for horizontal radio buttons.
|
|
||||||
|
|
||||||
<RadioButtonGroup legendText="Storage tier (disk)">
|
<RadioButtonGroup legendText="Storage tier (disk)">
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
|
@ -93,9 +91,7 @@ Show a loading state for horizontal radio buttons.
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
</RadioButtonGroup>
|
</RadioButtonGroup>
|
||||||
|
|
||||||
## Skeleton (vertical)
|
### Skeleton (vertical)
|
||||||
|
|
||||||
Show a loading state for vertical radio buttons.
|
|
||||||
|
|
||||||
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
<RadioButtonGroup orientation="vertical" legendText="Storage tier (disk)">
|
||||||
<RadioButtonSkeleton />
|
<RadioButtonSkeleton />
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
components: ["TileGroup", "RadioTile"]
|
components: ["TileGroup", "RadioTile"]
|
||||||
|
source: Tile/RadioTile.svelte
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -7,64 +8,54 @@ components: ["TileGroup", "RadioTile"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`RadioTile` provides a selectable tile interface for choosing a single option from a set. It supports both individual and grouped usage, with options for light and disabled states.
|
### Default
|
||||||
|
|
||||||
## Default
|
<TileGroup legend="Service pricing tiers">
|
||||||
|
<RadioTile value="0" checked>
|
||||||
Create a group of radio tiles with a shared name and legend.
|
|
||||||
|
|
||||||
<TileGroup legend="Service pricing tiers" name="plan" selected="standard">
|
|
||||||
<RadioTile value="lite">
|
|
||||||
Lite plan
|
Lite plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile value="standard">
|
<RadioTile value="1">
|
||||||
Standard plan
|
Standard plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile value="plus">
|
<RadioTile value="2">
|
||||||
Plus plan
|
Plus plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
</TileGroup>
|
</TileGroup>
|
||||||
|
|
||||||
## Reactive (one-way binding)
|
### Reactive (one-way binding)
|
||||||
|
|
||||||
Update the selected value using the `select` event.
|
|
||||||
|
|
||||||
<FileSource src="/framed/RadioTile/RadioTileReactiveOneWay" />
|
<FileSource src="/framed/RadioTile/RadioTileReactiveOneWay" />
|
||||||
|
|
||||||
## Reactive (two-way binding)
|
### Reactive (two-way binding)
|
||||||
|
|
||||||
Bind to the `selected` prop for simpler state management.
|
Binding to the `selected` prop is a more concise approach to managing state.
|
||||||
|
|
||||||
<FileSource src="/framed/RadioTile/RadioTileReactive" />
|
<FileSource src="/framed/RadioTile/RadioTileReactive" />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
<TileGroup legend="Service pricing tiers">
|
||||||
|
<RadioTile light value="0" checked>
|
||||||
<TileGroup legend="Service pricing tiers" name="plan-light" selected="standard">
|
|
||||||
<RadioTile light value="lite">
|
|
||||||
Lite plan
|
Lite plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile light value="standard">
|
<RadioTile light value="1">
|
||||||
Standard plan
|
Standard plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile light value="plus">
|
<RadioTile light value="2">
|
||||||
Plus plan
|
Plus plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
</TileGroup>
|
</TileGroup>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable specific tiles to prevent selection.
|
<TileGroup legend="Service pricing tiers">
|
||||||
|
<RadioTile value="0" checked>
|
||||||
<TileGroup legend="Service pricing tiers" name="plan-disabled" selected="standard">
|
|
||||||
<RadioTile value="lite" disabled>
|
|
||||||
Lite plan
|
Lite plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile value="standard">
|
<RadioTile value="1" disabled>
|
||||||
Standard plan
|
Standard plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
<RadioTile value="plus" disabled>
|
<RadioTile value="2" disabled>
|
||||||
Plus plan
|
Plus plan
|
||||||
</RadioTile>
|
</RadioTile>
|
||||||
</TileGroup>
|
</TileGroup>
|
|
@ -1,15 +1,11 @@
|
||||||
<script>
|
<script>
|
||||||
import { InlineNotification, RecursiveList, Link } from "carbon-components-svelte";
|
import { InlineNotification, RecursiveList } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`RecursiveList` provides a flexible way to render hierarchical data structures using either unordered or ordered lists. It supports nested nodes, links, and HTML content, making it ideal for displaying complex data hierarchies.
|
This component uses the [svelte:self API](https://svelte.dev/docs#svelte_self) to render the [UnorderedList](/components/UnorderedList) and [OrderedList](/components/OrderedList) components with tree structured data.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
A child node can render text, a link, HTML content, and other children.
|
||||||
<div class="body-short-01">
|
|
||||||
In version 0.86.0, the <strong>children</strong> prop was renamed to <strong>nodes</strong> for <Link target="_blank" href="https://svelte.dev/docs/svelte/v5-migration-guide#The-children-prop-is-reserved">Svelte 5 compatibility</Link>.
|
|
||||||
</div>
|
|
||||||
</InlineNotification>
|
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Warning:" kind="warning" hideCloseButton>
|
<InlineNotification svx-ignore lowContrast title="Warning:" kind="warning" hideCloseButton>
|
||||||
<div class="body-short-01">
|
<div class="body-short-01">
|
||||||
|
@ -17,26 +13,22 @@
|
||||||
</div>
|
</div>
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
||||||
## Default
|
### Unordered
|
||||||
|
|
||||||
Create a hierarchical list using the `nodes` prop. Each node can contain text, links, HTML content, and nested nodes.
|
The `children` prop accepts an array of child nodes.
|
||||||
|
|
||||||
|
By default, the list type is unordered.
|
||||||
|
|
||||||
<FileSource src="/framed/RecursiveList/RecursiveList" />
|
<FileSource src="/framed/RecursiveList/RecursiveList" />
|
||||||
|
|
||||||
## Ordered
|
### Ordered
|
||||||
|
|
||||||
Set `type` to `"ordered"` to use numbered lists with proper indentation.
|
Set `type` to `"ordered"` to use the ordered list variant.
|
||||||
|
|
||||||
<FileSource src="/framed/RecursiveList/RecursiveListOrdered" />
|
<FileSource src="/framed/RecursiveList/RecursiveListOrdered" />
|
||||||
|
|
||||||
## Ordered (native styles)
|
### Ordered (native styles)
|
||||||
|
|
||||||
Set `type` to `"ordered-native"` to use browser-native numbering styles.
|
Set `type` to `"ordered-native"` to use the native styles for an ordered list.
|
||||||
|
|
||||||
<FileSource src="/framed/RecursiveList/RecursiveListOrderedNative" />
|
<FileSource src="/framed/RecursiveList/RecursiveListOrderedNative" />
|
||||||
|
|
||||||
## Flat data structure
|
|
||||||
|
|
||||||
Convert flat data structures to hierarchical arrays using the `toHierarchy` utility function.
|
|
||||||
|
|
||||||
<FileSource src="/framed/RecursiveList/RecursiveListFlatArray" />
|
|
||||||
|
|
|
@ -4,78 +4,60 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Search` provides a flexible search input component with support for expandable variants, different sizes, and custom icons. It includes built-in functionality for clearing input and handling keyboard events.
|
### Default
|
||||||
|
|
||||||
## Default
|
The `Search` component size is extra-large by default. There are [large](#large-size) and [small](#small-size) size variants.
|
||||||
|
|
||||||
The search component is extra-large by default. Use the `size` prop to choose between [large](#large-size) and [small](#small-size) variants.
|
|
||||||
|
|
||||||
<Search />
|
<Search />
|
||||||
|
|
||||||
## Default value
|
### Default value
|
||||||
|
|
||||||
Set an initial value using the `value` prop.
|
|
||||||
|
|
||||||
<Search placeholder="Search catalog..." value="Cloud functions" />
|
<Search placeholder="Search catalog..." value="Cloud functions" />
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
Bind to the `value` prop for reactive updates.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Search/SearchReactive" />
|
<FileSource src="/framed/Search/SearchReactive" />
|
||||||
|
|
||||||
## Clear event
|
### on:clear
|
||||||
|
|
||||||
The `clear` event is dispatched when clicking the clear button or pressing the Escape key.
|
The "clear" event is dispatched when clicking the "X" button or when pressing the "Escape" key.
|
||||||
|
|
||||||
<Search value="Cloud functions" on:clear={() => console.log('clear')}/>
|
<Search value="Cloud functions" on:clear={() => console.log('clear')}/>
|
||||||
|
|
||||||
## Expandable variant
|
### Expandable variant
|
||||||
|
|
||||||
Enable the expandable variant to show a compact search icon that expands on focus.
|
Set `expandable` to `true` to use the expandable variant.
|
||||||
|
|
||||||
<FileSource src="/framed/Search/SearchExpandableReactive" />
|
<FileSource src="/framed/Search/SearchExpandableReactive" />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
|
||||||
|
|
||||||
<Search light />
|
<Search light />
|
||||||
|
|
||||||
## Large size
|
### Large size
|
||||||
|
|
||||||
Set `size` to `"lg"` for a large search input.
|
|
||||||
|
|
||||||
<Search size="lg" />
|
<Search size="lg" />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Set `size` to `"sm"` for a small search input.
|
|
||||||
|
|
||||||
<Search size="sm" />
|
<Search size="sm" />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the search input using the `disabled` prop.
|
|
||||||
|
|
||||||
<Search disabled />
|
<Search disabled />
|
||||||
|
|
||||||
## Custom icon
|
### Custom search icon
|
||||||
|
|
||||||
Replace the default search icon with a custom one.
|
|
||||||
|
|
||||||
<Search icon={Query} />
|
<Search icon={Query} />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Display a loading state using the skeleton variant.
|
|
||||||
|
|
||||||
<Search skeleton />
|
<Search skeleton />
|
||||||
|
|
||||||
## Skeleton (large)
|
### Skeleton (large)
|
||||||
|
|
||||||
<Search size="lg" skeleton />
|
<Search size="lg" skeleton />
|
||||||
|
|
||||||
## Skeleton (small)
|
### Skeleton (small)
|
||||||
|
|
||||||
<Search size="sm" skeleton />
|
<Search size="sm" skeleton />
|
|
@ -7,25 +7,9 @@ components: ["Select", "SelectItem", "SelectItemGroup", "SelectSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Select` provides a dropdown menu for selecting a single option from a list. It supports various states, sizes, and includes built-in validation and helper text.
|
### Default
|
||||||
|
|
||||||
## Default
|
<Select labelText="Carbon theme" selected="g10" >
|
||||||
|
|
||||||
Create a basic select menu with `SelectItem` components. The first item's value is used as the default if `selected` is not set.
|
|
||||||
|
|
||||||
<Select labelText="Carbon theme" on:change={e => console.log("value", e.target.value)}>
|
|
||||||
<SelectItem value="white" />
|
|
||||||
<SelectItem value="g10" />
|
|
||||||
<SelectItem value="g80" />
|
|
||||||
<SelectItem value="g90" />
|
|
||||||
<SelectItem value="g100" />
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
## Custom item text
|
|
||||||
|
|
||||||
Use the `text` prop to customize the display text of each option.
|
|
||||||
|
|
||||||
<Select labelText="Carbon theme" on:change={e => console.log("value", e.target.value)}>
|
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
<SelectItem value="g80" text="Gray 80" />
|
<SelectItem value="g80" text="Gray 80" />
|
||||||
|
@ -33,27 +17,11 @@ Use the `text` prop to customize the display text of each option.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Initial selected value
|
### Reactive example
|
||||||
|
|
||||||
Set the initial selection using the `selected` prop.
|
|
||||||
|
|
||||||
<Select labelText="Carbon theme" selected="g10" on:change={e => console.log("value", e.target.value)}>
|
|
||||||
<SelectItem value="white" text="White" />
|
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
|
||||||
<SelectItem value="g80" text="Gray 80" />
|
|
||||||
<SelectItem value="g90" text="Gray 90" />
|
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
## Reactive example
|
|
||||||
|
|
||||||
The `selected` prop supports two-way binding for reactive updates.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Select/SelectReactive" />
|
<FileSource src="/framed/Select/SelectReactive" />
|
||||||
|
|
||||||
## Helper text
|
### Helper text
|
||||||
|
|
||||||
Add descriptive text below the select menu.
|
|
||||||
|
|
||||||
<Select helperText="Carbon offers 4 themes (2 light, 3 dark)" labelText="Carbon theme" selected="g10" >
|
<Select helperText="Carbon offers 4 themes (2 light, 3 dark)" labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -63,9 +31,7 @@ Add descriptive text below the select menu.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility.
|
|
||||||
|
|
||||||
<Select hideLabel labelText="Carbon theme" selected="g10" >
|
<Select hideLabel labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -75,9 +41,7 @@ Visually hide the label while maintaining accessibility.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Item groups
|
### Item groups
|
||||||
|
|
||||||
Group related options using `SelectItemGroup` components.
|
|
||||||
|
|
||||||
<Select labelText="Carbon theme" selected="0">
|
<Select labelText="Carbon theme" selected="0">
|
||||||
<SelectItem value="0" text="Select a theme" disabled hidden />
|
<SelectItem value="0" text="Select a theme" disabled hidden />
|
||||||
|
@ -92,45 +56,7 @@ Group related options using `SelectItemGroup` components.
|
||||||
</SelectItemGroup>
|
</SelectItemGroup>
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Small size
|
### Light variant
|
||||||
|
|
||||||
Use the small size variant for compact layouts.
|
|
||||||
|
|
||||||
<Select size="sm" labelText="Carbon theme" selected="g10" >
|
|
||||||
<SelectItem value="white" text="White" />
|
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
|
||||||
<SelectItem value="g80" text="Gray 80" />
|
|
||||||
<SelectItem value="g90" text="Gray 90" />
|
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
## Extra-large size
|
|
||||||
|
|
||||||
Use the extra-large size variant for prominent selections.
|
|
||||||
|
|
||||||
<Select size="xl" labelText="Carbon theme" selected="g10" >
|
|
||||||
<SelectItem value="white" text="White" />
|
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
|
||||||
<SelectItem value="g80" text="Gray 80" />
|
|
||||||
<SelectItem value="g90" text="Gray 90" />
|
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
## Inline variant
|
|
||||||
|
|
||||||
Use the inline variant for horizontal layouts.
|
|
||||||
|
|
||||||
<Select inline labelText="Carbon theme" selected="g10" >
|
|
||||||
<SelectItem value="white" text="White" />
|
|
||||||
<SelectItem value="g10" text="Gray 10" />
|
|
||||||
<SelectItem value="g80" text="Gray 80" />
|
|
||||||
<SelectItem value="g90" text="Gray 90" />
|
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
|
||||||
</Select>
|
|
||||||
|
|
||||||
## Light variant
|
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
|
||||||
|
|
||||||
<Select light labelText="Carbon theme" selected="g10" >
|
<Select light labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -140,9 +66,37 @@ Use the light variant for light backgrounds.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Invalid state
|
### Inline variant
|
||||||
|
|
||||||
Show validation errors using the invalid state.
|
<Select inline labelText="Carbon theme" selected="g10" >
|
||||||
|
<SelectItem value="white" text="White" />
|
||||||
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
|
<SelectItem value="g80" text="Gray 80" />
|
||||||
|
<SelectItem value="g90" text="Gray 90" />
|
||||||
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
### Extra-large size
|
||||||
|
|
||||||
|
<Select size="xl" labelText="Carbon theme" selected="g10" >
|
||||||
|
<SelectItem value="white" text="White" />
|
||||||
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
|
<SelectItem value="g80" text="Gray 80" />
|
||||||
|
<SelectItem value="g90" text="Gray 90" />
|
||||||
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
### Small size
|
||||||
|
|
||||||
|
<Select size="sm" labelText="Carbon theme" selected="g10" >
|
||||||
|
<SelectItem value="white" text="White" />
|
||||||
|
<SelectItem value="g10" text="Gray 10" />
|
||||||
|
<SelectItem value="g80" text="Gray 80" />
|
||||||
|
<SelectItem value="g90" text="Gray 90" />
|
||||||
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
|
</Select>
|
||||||
|
|
||||||
|
### Invalid state
|
||||||
|
|
||||||
<Select invalid invalidText="Theme must be a dark variant" labelText="Carbon theme" selected="g10" >
|
<Select invalid invalidText="Theme must be a dark variant" labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -152,9 +106,7 @@ Show validation errors using the invalid state.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Show warnings using the warning state.
|
|
||||||
|
|
||||||
<Select warn warnText="The selected theme will not be persisted" labelText="Carbon theme" selected="g10" >
|
<Select warn warnText="The selected theme will not be persisted" labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -164,9 +116,7 @@ Show warnings using the warning state.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the select menu to prevent interaction.
|
|
||||||
|
|
||||||
<Select disabled labelText="Carbon theme" selected="g10" >
|
<Select disabled labelText="Carbon theme" selected="g10" >
|
||||||
<SelectItem value="white" text="White" />
|
<SelectItem value="white" text="White" />
|
||||||
|
@ -176,12 +126,10 @@ Disable the select menu to prevent interaction.
|
||||||
<SelectItem value="g100" text="Gray 100" />
|
<SelectItem value="g100" text="Gray 100" />
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Display a loading state using the skeleton variant.
|
|
||||||
|
|
||||||
<SelectSkeleton />
|
<SelectSkeleton />
|
||||||
|
|
||||||
## Skeleton (hidden label)
|
### Skeleton (hidden label)
|
||||||
|
|
||||||
<SelectSkeleton hideLabel />
|
<SelectSkeleton hideLabel />
|
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
components: ["SelectableTile"]
|
components: ["SelectableTile"]
|
||||||
|
source: Tile/SelectableTile.svelte
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -7,11 +8,7 @@ components: ["SelectableTile"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`SelectableTile` provides a tile-based selection interface that allows users to select multiple options. It supports various states and includes built-in keyboard navigation and accessibility features.
|
### Multi-selectable tiles
|
||||||
|
|
||||||
## Multi-selectable tiles
|
|
||||||
|
|
||||||
Group multiple selectable tiles together for multi-selection scenarios.
|
|
||||||
|
|
||||||
<div role="group" aria-label="selectable tiles">
|
<div role="group" aria-label="selectable tiles">
|
||||||
<SelectableTile selected>
|
<SelectableTile selected>
|
||||||
|
@ -25,9 +22,7 @@ Group multiple selectable tiles together for multi-selection scenarios.
|
||||||
</SelectableTile>
|
</SelectableTile>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
|
||||||
|
|
||||||
<div role="group" aria-label="selectable tiles">
|
<div role="group" aria-label="selectable tiles">
|
||||||
<SelectableTile light selected>
|
<SelectableTile light selected>
|
||||||
|
@ -41,9 +36,7 @@ Use the light variant for light backgrounds.
|
||||||
</SelectableTile>
|
</SelectableTile>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable tiles to prevent interaction.
|
|
||||||
|
|
||||||
<div role="group" aria-label="selectable tiles">
|
<div role="group" aria-label="selectable tiles">
|
||||||
<SelectableTile selected>
|
<SelectableTile selected>
|
||||||
|
|
|
@ -3,16 +3,10 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`SkeletonPlaceholder` provides a loading state placeholder that can be used to indicate content is being loaded. It supports custom sizing and forwards mouse events for interactive loading states.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic skeleton placeholder with default styling.
|
|
||||||
|
|
||||||
<SkeletonPlaceholder />
|
<SkeletonPlaceholder />
|
||||||
|
|
||||||
## Custom size
|
### Custom size
|
||||||
|
|
||||||
Specify custom dimensions using the `style` prop.
|
|
||||||
|
|
||||||
<SkeletonPlaceholder style="height: 12rem; width: 12rem;" />
|
<SkeletonPlaceholder style="height: 12rem; width: 12rem;" />
|
||||||
|
|
|
@ -3,34 +3,22 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`SkeletonText` provides a loading state for text content with support for different sizes and line counts. It's commonly used to indicate that text content is being loaded.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic skeleton text with default styling.
|
|
||||||
|
|
||||||
<SkeletonText />
|
<SkeletonText />
|
||||||
|
|
||||||
## Heading variant
|
### Heading variant
|
||||||
|
|
||||||
Use the heading variant for larger text placeholders.
|
|
||||||
|
|
||||||
<SkeletonText heading />
|
<SkeletonText heading />
|
||||||
|
|
||||||
## Paragraph variant
|
### Paragraph variant
|
||||||
|
|
||||||
Use the paragraph variant for multi-line text placeholders.
|
|
||||||
|
|
||||||
<SkeletonText paragraph />
|
<SkeletonText paragraph />
|
||||||
|
|
||||||
## Paragraph with custom line count
|
### Paragraph with custom line count
|
||||||
|
|
||||||
Specify the number of lines to render using the `lines` prop.
|
|
||||||
|
|
||||||
<SkeletonText paragraph lines={8} />
|
<SkeletonText paragraph lines={8} />
|
||||||
|
|
||||||
## Paragraph with max width
|
### Paragraph with max width
|
||||||
|
|
||||||
Set a custom width for the text placeholder using the `width` prop.
|
|
||||||
|
|
||||||
<SkeletonText paragraph width="50%" />
|
<SkeletonText paragraph width="50%" />
|
|
@ -7,70 +7,38 @@ components: ["Slider", "SliderSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Slider` provides a visual way to select a value from a range. It supports keyboard navigation, custom ranges, step values, and various states.
|
### Default
|
||||||
|
|
||||||
## Default
|
<Slider />
|
||||||
|
|
||||||
Create a basic slider with a label and default range (0-100).
|
### Hidden text input
|
||||||
|
|
||||||
<Slider labelText="Instances" value={0} />
|
<Slider hideTextInput />
|
||||||
|
|
||||||
## Full width
|
### Custom minimum, maximum values
|
||||||
|
|
||||||
Set `fullWidth` to `true` for the slider to span the full width of its containing element.
|
|
||||||
|
|
||||||
<Slider labelText="Instances" fullWidth value={0} />
|
|
||||||
|
|
||||||
## Hidden label
|
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility.
|
|
||||||
|
|
||||||
<Slider labelText="Instances" hideLabel value={0} />
|
|
||||||
|
|
||||||
## Hidden text input
|
|
||||||
|
|
||||||
Hide the text input while keeping the slider functionality.
|
|
||||||
|
|
||||||
<Slider labelText="Instances" hideTextInput value={0} />
|
|
||||||
|
|
||||||
## Custom minimum, maximum values
|
|
||||||
|
|
||||||
Set custom range values and labels.
|
|
||||||
|
|
||||||
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} />
|
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} />
|
||||||
|
|
||||||
## Custom step value
|
### Custom step value
|
||||||
|
|
||||||
Specify the step value for more precise control.
|
|
||||||
|
|
||||||
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
<Slider labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light backgrounds.
|
<Slider light labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||||
|
|
||||||
<Slider light labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
### Invalid state
|
||||||
|
|
||||||
## Invalid state
|
<Slider invalid labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||||
|
|
||||||
Indicate an invalid state with the `invalid` prop.
|
### Disabled state
|
||||||
|
|
||||||
<Slider invalid labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
<Slider disabled labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
||||||
|
|
||||||
## Disabled state
|
### Skeleton
|
||||||
|
|
||||||
Disable the slider to prevent interaction.
|
|
||||||
|
|
||||||
<Slider disabled labelText="Runtime memory (MB)" min={10} max={990} maxLabel="990 MB" value={100} step={10} />
|
|
||||||
|
|
||||||
## Skeleton
|
|
||||||
|
|
||||||
Show a loading state with the skeleton variant.
|
|
||||||
|
|
||||||
<SliderSkeleton />
|
<SliderSkeleton />
|
||||||
|
|
||||||
## Skeleton (hidden label)
|
### Skeleton (hidden label)
|
||||||
|
|
||||||
Show a loading state without a label.
|
|
||||||
|
|
||||||
<SliderSkeleton hideLabel />
|
<SliderSkeleton hideLabel />
|
|
@ -3,16 +3,12 @@ components: ["StructuredList", "StructuredListSkeleton", "StructuredListBody", "
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { StructuredList, StructuredListSkeleton, StructuredListBody, StructuredListHead, StructuredListCell, StructuredListRow, StructuredListInput } from "carbon-components-svelte";
|
import { StructuredList, StructuredListSkeleton, StructuredListBody, StructuredListHead, StructuredListCell ,StructuredListRow, StructuredListInput } from "carbon-components-svelte";
|
||||||
import CheckmarkFilled from "carbon-icons-svelte/lib/CheckmarkFilled.svelte";
|
import CheckmarkFilled from "carbon-icons-svelte/lib/CheckmarkFilled.svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`StructuredList` provides a semantic way to display tabular data with support for selection, keyboard navigation, and various layout options.
|
### Default (read-only)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic structured list with headers and rows by default.
|
|
||||||
|
|
||||||
<StructuredList>
|
<StructuredList>
|
||||||
<StructuredListHead>
|
<StructuredListHead>
|
||||||
|
@ -24,26 +20,39 @@ Display a basic structured list with headers and rows by default.
|
||||||
</StructuredListHead>
|
</StructuredListHead>
|
||||||
<StructuredListBody>
|
<StructuredListBody>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 1</StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
<StructuredListCell>Row 1</StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 2</StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
<StructuredListCell>Row 2</StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 3</StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
<StructuredListCell>Row 3</StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
</StructuredListBody>
|
</StructuredListBody>
|
||||||
</StructuredList>
|
</StructuredList>
|
||||||
|
|
||||||
## Condensed variant
|
### Condensed variant
|
||||||
|
|
||||||
Use the condensed variant for more compact rows.
|
|
||||||
|
|
||||||
<StructuredList condensed>
|
<StructuredList condensed>
|
||||||
<StructuredListHead>
|
<StructuredListHead>
|
||||||
|
@ -55,26 +64,39 @@ Use the condensed variant for more compact rows.
|
||||||
</StructuredListHead>
|
</StructuredListHead>
|
||||||
<StructuredListBody>
|
<StructuredListBody>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 1</StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
<StructuredListCell>Row 1</StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 1</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 2</StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
<StructuredListCell>Row 2</StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 2</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
<StructuredListRow>
|
<StructuredListRow>
|
||||||
|
<StructuredListCell noWrap>Row 3</StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
<StructuredListCell>Row 3</StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
<StructuredListCell>
|
||||||
<StructuredListCell>Row 3</StructuredListCell>
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc dui
|
||||||
|
magna, finibus id tortor sed, aliquet bibendum augue. Aenean posuere
|
||||||
|
sem vel euismod dignissim. Nulla ut cursus dolor. Pellentesque
|
||||||
|
vulputate nisl a porttitor interdum.
|
||||||
|
</StructuredListCell>
|
||||||
</StructuredListRow>
|
</StructuredListRow>
|
||||||
</StructuredListBody>
|
</StructuredListBody>
|
||||||
</StructuredList>
|
</StructuredList>
|
||||||
|
|
||||||
## Flush variant
|
### Flush
|
||||||
|
|
||||||
Use the flush variant to remove padding from the list.
|
|
||||||
|
|
||||||
<StructuredList flush>
|
<StructuredList flush>
|
||||||
<StructuredListHead>
|
<StructuredListHead>
|
||||||
|
@ -118,9 +140,7 @@ Use the flush variant to remove padding from the list.
|
||||||
</StructuredListBody>
|
</StructuredListBody>
|
||||||
</StructuredList>
|
</StructuredList>
|
||||||
|
|
||||||
## Selectable rows
|
### Selectable rows
|
||||||
|
|
||||||
Enable row selection with the `selection` prop and `StructuredListInput` components.
|
|
||||||
|
|
||||||
<StructuredList selection selected="row-1-value">
|
<StructuredList selection selected="row-1-value">
|
||||||
<StructuredListHead>
|
<StructuredListHead>
|
||||||
|
@ -160,8 +180,6 @@ Enable row selection with the `selection` prop and `StructuredListInput` compone
|
||||||
</StructuredListBody>
|
</StructuredListBody>
|
||||||
</StructuredList>
|
</StructuredList>
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Show a loading state with the skeleton variant.
|
|
||||||
|
|
||||||
<StructuredListSkeleton rows={3} />
|
<StructuredListSkeleton rows={3} />
|
|
@ -7,11 +7,7 @@ components: ["Tabs", "Tab", "TabContent", "TabsSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Tabs` provides a way to organize content into separate views that can be switched between. It supports keyboard navigation, disabled states, and various layout options.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic tab interface with labels and content.
|
|
||||||
|
|
||||||
<Tabs>
|
<Tabs>
|
||||||
<Tab label="Tab label 1" />
|
<Tab label="Tab label 1" />
|
||||||
|
@ -24,9 +20,11 @@ Create a basic tab interface with labels and content.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Auto width
|
### Auto width
|
||||||
|
|
||||||
By default, each tab has a fixed width of `10rem`. Set `autoWidth` to `true` for tabs to automatically adjust their width based on content.
|
By default, the width of each tab is set to `10rem`.
|
||||||
|
|
||||||
|
Set `autoWidth` to `true` for tabs to have an automatically set width.
|
||||||
|
|
||||||
<Tabs autoWidth>
|
<Tabs autoWidth>
|
||||||
<Tab label="Tab label 1" />
|
<Tab label="Tab label 1" />
|
||||||
|
@ -39,32 +37,11 @@ By default, each tab has a fixed width of `10rem`. Set `autoWidth` to `true` for
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
Use `bind:selected` to create a two-way binding with the selected tab index. This allows you to programmatically control the selected tab and react to tab changes.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Tabs/TabsReactive" />
|
<FileSource src="/framed/Tabs/TabsReactive" />
|
||||||
|
|
||||||
## Disabled tabs
|
### Container type
|
||||||
|
|
||||||
Set `disabled` to `true` on a `Tab` component to prevent interaction. Keyboard navigation will skip disabled tabs.
|
|
||||||
|
|
||||||
<Tabs>
|
|
||||||
<Tab label="Tab label 1" />
|
|
||||||
<Tab label="Tab label 2" disabled />
|
|
||||||
<Tab label="Tab label 3" disabled />
|
|
||||||
<Tab label="Tab label 4" />
|
|
||||||
<svelte:fragment slot="content">
|
|
||||||
<TabContent>Content 1</TabContent>
|
|
||||||
<TabContent>Content 2</TabContent>
|
|
||||||
<TabContent>Content 3</TabContent>
|
|
||||||
<TabContent>Content 4</TabContent>
|
|
||||||
</svelte:fragment>
|
|
||||||
</Tabs>
|
|
||||||
|
|
||||||
## Container type
|
|
||||||
|
|
||||||
Use the container type for a more prominent tab interface.
|
|
||||||
|
|
||||||
<Tabs type="container">
|
<Tabs type="container">
|
||||||
<Tab label="Tab label 1" />
|
<Tab label="Tab label 1" />
|
||||||
|
@ -77,14 +54,10 @@ Use the container type for a more prominent tab interface.
|
||||||
</svelte:fragment>
|
</svelte:fragment>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
||||||
## Skeleton (default)
|
### Skeleton (default)
|
||||||
|
|
||||||
Show a loading state with the default skeleton variant.
|
|
||||||
|
|
||||||
<TabsSkeleton count={3} />
|
<TabsSkeleton count={3} />
|
||||||
|
|
||||||
## Skeleton (container)
|
### Skeleton (container)
|
||||||
|
|
||||||
Show a loading state with the container skeleton variant.
|
|
||||||
|
|
||||||
<TabsSkeleton type="container" count={3} />
|
<TabsSkeleton type="container" count={3} />
|
|
@ -1,30 +1,18 @@
|
||||||
---
|
|
||||||
components: ["Tag", "TagSkeleton"]
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Tag, TooltipDefinition } from "carbon-components-svelte";
|
import { Tag } from "carbon-components-svelte";
|
||||||
import IbmCloud from "carbon-icons-svelte/lib/IbmCloud.svelte";
|
import IbmCloud from "carbon-icons-svelte/lib/IbmCloud.svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Tag` provides a way to categorize content with a keyword or label. It supports various styles, sizes, and interactive states, including filterable and interactive variants.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic tag with text content.
|
|
||||||
|
|
||||||
<Tag>IBM Cloud</Tag>
|
<Tag>IBM Cloud</Tag>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size variant for more compact layouts.
|
|
||||||
|
|
||||||
<Tag size="sm">IBM Cloud</Tag>
|
<Tag size="sm">IBM Cloud</Tag>
|
||||||
|
|
||||||
## Tag types
|
### Tag types
|
||||||
|
|
||||||
Choose from a variety of color types to match your design system.
|
|
||||||
|
|
||||||
<Tag type="red">red</Tag>
|
<Tag type="red">red</Tag>
|
||||||
<Tag type="magenta">magenta</Tag>
|
<Tag type="magenta">magenta</Tag>
|
||||||
|
@ -39,61 +27,41 @@ Choose from a variety of color types to match your design system.
|
||||||
<Tag type="high-contrast">high-contrast</Tag>
|
<Tag type="high-contrast">high-contrast</Tag>
|
||||||
<Tag type="outline">outline</Tag>
|
<Tag type="outline">outline</Tag>
|
||||||
|
|
||||||
## Filterable
|
### Filterable
|
||||||
|
|
||||||
Create a filterable tag with a close button that dispatches a `close` event when clicked.
|
|
||||||
|
|
||||||
<Tag filter on:close>carbon-components</Tag>
|
<Tag filter on:close>carbon-components</Tag>
|
||||||
|
|
||||||
## Filterable (disabled)
|
### Filterable (disabled)
|
||||||
|
|
||||||
Disable a filterable tag to prevent interaction.
|
|
||||||
|
|
||||||
<Tag filter disabled on:close>carbon-components</Tag>
|
<Tag filter disabled on:close>carbon-components</Tag>
|
||||||
|
|
||||||
## Filterable (small)
|
### Filterable (small)
|
||||||
|
|
||||||
Combine the filterable variant with the small size.
|
|
||||||
|
|
||||||
<Tag size="sm" filter on:close>carbon-components</Tag>
|
<Tag size="sm" filter on:close>carbon-components</Tag>
|
||||||
|
|
||||||
## Custom icon
|
### Custom icon
|
||||||
|
|
||||||
Add a custom icon to the tag. Note: custom icons cannot be used with the filterable variant.
|
Note: rendering a custom icon cannnot be used with the filterable variant.
|
||||||
|
|
||||||
<Tag icon={IbmCloud}>IBM Cloud</Tag>
|
<Tag icon={IbmCloud}>IBM Cloud</Tag>
|
||||||
|
|
||||||
## Interactive variant
|
### Interactive variant
|
||||||
|
|
||||||
Set `interactive` to `true` to render a `button` element instead of a `div`. This is useful for clickable tags.
|
Set `interactive` to `true` to render a `button` element instead of a `div`.
|
||||||
|
|
||||||
<Tag interactive>Machine learning</Tag>
|
<Tag interactive>Machine learning</Tag>
|
||||||
|
|
||||||
## Disabled
|
### Disabled
|
||||||
|
|
||||||
Both filterable and interactive tag variants support a disabled state.
|
The filterable and interactive tag variants have a disabled state.
|
||||||
|
|
||||||
<Tag filter disabled>Machine learning</Tag>
|
<Tag filter disabled>Machine learning</Tag>
|
||||||
<Tag interactive disabled>Machine learning</Tag>
|
<Tag interactive disabled>Machine learning</Tag>
|
||||||
|
|
||||||
## Tooltip in a tag
|
### Skeleton
|
||||||
|
|
||||||
Embed a tooltip within a tag to provide additional context.
|
|
||||||
|
|
||||||
<Tag>
|
|
||||||
<TooltipDefinition tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
|
||||||
Armonk
|
|
||||||
</TooltipDefinition>
|
|
||||||
</Tag>
|
|
||||||
|
|
||||||
## Skeleton
|
|
||||||
|
|
||||||
Show a loading state with the default skeleton variant.
|
|
||||||
|
|
||||||
<Tag skeleton />
|
<Tag skeleton />
|
||||||
|
|
||||||
## Skeleton (small)
|
### Skeleton (small)
|
||||||
|
|
||||||
Show a loading state with the small skeleton variant.
|
|
||||||
|
|
||||||
<Tag size="sm" skeleton />
|
<Tag size="sm" skeleton />
|
|
@ -7,64 +7,46 @@ components: ["TextArea", "TextAreaSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`TextArea` provides a multi-line text input field with support for various states, character counting, and accessibility features. It's ideal for longer text input like descriptions, comments, or messages.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic textarea with a label and placeholder text.
|
|
||||||
|
|
||||||
<TextArea labelText="App description" placeholder="Enter a description..." />
|
<TextArea labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Maximum character count
|
### Maximum character count
|
||||||
|
|
||||||
Specify the max character count using the `maxCount` prop. A character counter will be displayed to the right of the label. You can also use the native `maxlength` attribute if you prefer not to show a counter.
|
Specify the max character count using the `maxCount` prop. A character counter will be displayed to the right of the label.
|
||||||
|
|
||||||
|
You can always use the native `maxlength` attribute if you'd prefer that a counter not be shown.
|
||||||
|
|
||||||
<TextArea labelText="App description" placeholder="Enter a description..." maxCount={100} />
|
<TextArea labelText="App description" placeholder="Enter a description..." maxCount={100} />
|
||||||
|
|
||||||
## With helper text
|
### With helper text
|
||||||
|
|
||||||
Add helper text below the textarea to provide additional context or instructions.
|
|
||||||
|
|
||||||
<TextArea labelText="App description" helperText="A rich description helps us better recommend related products and services" placeholder="Enter a description..." />
|
<TextArea labelText="App description" helperText="A rich description helps us better recommend related products and services" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility by setting `hideLabel` to `true`.
|
|
||||||
|
|
||||||
<TextArea hideLabel labelText="App description" placeholder="Enter a description..." />
|
<TextArea hideLabel labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
|
||||||
|
|
||||||
<TextArea light labelText="App description" placeholder="Enter a description..." />
|
<TextArea light labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Custom rows
|
### Custom rows
|
||||||
|
|
||||||
Adjust the number of visible rows using the `rows` prop. The default is 4 rows.
|
|
||||||
|
|
||||||
<TextArea rows={10} labelText="App description" placeholder="Enter a description..." />
|
<TextArea rows={10} labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
|
||||||
|
|
||||||
<TextArea invalid invalidText="Only plain text characters are allowed" labelText="App description" placeholder="Enter a description..." />
|
<TextArea invalid invalidText="Only plain text characters are allowed" labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the textarea to prevent user interaction by setting `disabled` to `true`.
|
|
||||||
|
|
||||||
<TextArea disabled labelText="App description" placeholder="Enter a description..." />
|
<TextArea disabled labelText="App description" placeholder="Enter a description..." />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Show a loading state with the default skeleton variant.
|
|
||||||
|
|
||||||
<TextAreaSkeleton />
|
<TextAreaSkeleton />
|
||||||
|
|
||||||
## Skeleton without label
|
### Skeleton without label
|
||||||
|
|
||||||
Show a loading state without a label by setting `hideLabel` to `true`.
|
|
||||||
|
|
||||||
<TextAreaSkeleton hideLabel />
|
<TextAreaSkeleton hideLabel />
|
|
@ -7,82 +7,54 @@ components: ["TextInput", "TextInputSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`TextInput` provides a single-line text input field with support for various states, sizes, and accessibility features. It's ideal for short text input like usernames, search terms, or form fields.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic text input with a label and placeholder text.
|
|
||||||
|
|
||||||
<TextInput labelText="User name" placeholder="Enter user name..." />
|
<TextInput labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## With helper text
|
### With helper text
|
||||||
|
|
||||||
Add helper text below the input to provide additional context or instructions.
|
|
||||||
|
|
||||||
<TextInput labelText="User name" helperText="Your user name is associated with your email" placeholder="Enter user name..." />
|
<TextInput labelText="User name" helperText="Your user name is associated with your email" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Hidden label
|
### Hidden label
|
||||||
|
|
||||||
Visually hide the label while maintaining accessibility by setting `hideLabel` to `true`.
|
|
||||||
|
|
||||||
<TextInput hideLabel labelText="User name" placeholder="Enter user name..." />
|
<TextInput hideLabel labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
|
||||||
|
|
||||||
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
<TextInput light labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Inline variant
|
### Inline variant
|
||||||
|
|
||||||
Use the inline variant to display the label and input on the same line by setting `inline` to `true`.
|
|
||||||
|
|
||||||
<TextInput inline labelText="User name" placeholder="Enter user name..." />
|
<TextInput inline labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Read-only variant
|
### Read-only variant
|
||||||
|
|
||||||
Display a non-editable value by setting `readonly` to `true`.
|
|
||||||
|
|
||||||
<TextInput readonly labelText="User name" value="IBM" />
|
<TextInput readonly labelText="User name" value="IBM" />
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Use the extra-large size for more prominent inputs by setting `size` to `"xl"`.
|
|
||||||
|
|
||||||
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." />
|
<TextInput size="xl" labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size for more compact inputs by setting `size` to `"sm"`.
|
|
||||||
|
|
||||||
<TextInput size="sm" labelText="User name" placeholder="Enter user name..." />
|
<TextInput size="sm" labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
|
||||||
|
|
||||||
<TextInput invalid invalidText="User name is already taken. Please try another." labelText="User name" placeholder="Enter user name..." />
|
<TextInput invalid invalidText="User name is already taken. Please try another." labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Warning state
|
### Warning state
|
||||||
|
|
||||||
Indicate a warning state with a message by setting `warn` to `true` and providing `warnText`.
|
|
||||||
|
|
||||||
<TextInput warn warnText="Your user name is different from your log in ID." labelText="User name" placeholder="Enter user name..." />
|
<TextInput warn warnText="Your user name is different from your log in ID." labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Disabled state
|
### Disabled state
|
||||||
|
|
||||||
Disable the input to prevent user interaction by setting `disabled` to `true`.
|
|
||||||
|
|
||||||
<TextInput disabled labelText="User name" placeholder="Enter user name..." />
|
<TextInput disabled labelText="User name" placeholder="Enter user name..." />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Show a loading state with the default skeleton variant.
|
|
||||||
|
|
||||||
<TextInputSkeleton />
|
<TextInputSkeleton />
|
||||||
|
|
||||||
## Skeleton without label
|
### Skeleton without label
|
||||||
|
|
||||||
Show a loading state without a label by setting `hideLabel` to `true`.
|
|
||||||
|
|
||||||
<TextInputSkeleton hideLabel />
|
<TextInputSkeleton hideLabel />
|
|
@ -1,62 +1,46 @@
|
||||||
---
|
|
||||||
components: ["Theme"]
|
|
||||||
---
|
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { InlineNotification, CodeSnippet } from "carbon-components-svelte";
|
import { Theme } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
|
|
||||||
let code = `import "carbon-components-svelte/css/all.css";`;
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
The `Theme` component provides dynamic client-side theming using CSS variables. It supports five Carbon themes: white, g10, g80, g90, and g100, and allows for custom theme token overrides. The component can persist theme preferences using [window.localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage) and provides built-in toggle and select controls for theme switching.
|
This utility component dynamically updates the Carbon theme on the client-side using CSS variables.
|
||||||
|
|
||||||
<InlineNotification svx-ignore lowContrast title="Note:" kind="info" hideCloseButton>
|
### Default
|
||||||
<div class="body-short-01">You must use the "all.css" StyleSheet with the <code>Theme</code> component.</div>
|
|
||||||
</InlineNotification>
|
|
||||||
|
|
||||||
The `all.css` StyleSheet uses [CSS variables](https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties) for dynamic theming.
|
|
||||||
|
|
||||||
<CodeSnippet svx-ignore {code} />
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic theme component that can be controlled programmatically.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/Theme" />
|
<FileSource src="/framed/Theme/Theme" />
|
||||||
|
|
||||||
## Persist locally
|
### Persist locally
|
||||||
|
|
||||||
Set `persist` to `true` to save the theme preference in [localStorage](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage). Use `persistKey` to specify a custom storage key.
|
Set `persist` to `true` to persist the theme locally using the [Window.localStorage API](https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage).
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemePersist" />
|
<FileSource src="/framed/Theme/ThemePersist" />
|
||||||
|
|
||||||
## Custom theme
|
### Custom theme
|
||||||
|
|
||||||
Override default Carbon theme tokens by providing custom key-value pairs in the `tokens` prop. Refer to the [Carbon website](https://carbondesignsystem.com/guidelines/themes/overview#customizing-a-theme) for guidance on customizing themes.
|
Define keys and values in the `tokens` prop that override default Carbon theme tokens. Refer to the [Carbon website](https://carbondesignsystem.com/guidelines/themes/overview#customizing-a-theme) for guidance on customizing a theme using token values.
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemeTokens" />
|
<FileSource src="/framed/Theme/ThemeTokens" />
|
||||||
|
|
||||||
## Theme toggle
|
### Theme toggle
|
||||||
|
|
||||||
Set `render` to `"toggle"` to display a toggle switch for switching between two themes. By default, it toggles between "white" and "g100" themes.
|
Set `render` to `"toggle"` to render a toggle switch to control the theme.
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemeToggle" />
|
<FileSource src="/framed/Theme/ThemeToggle" />
|
||||||
|
|
||||||
## Theme toggle (custom)
|
### Theme toggle (custom)
|
||||||
|
|
||||||
Customize the toggle appearance and behavior using the `toggle` prop. You can specify custom themes, labels, and other toggle properties.
|
Customize the toggle using the `toggle` prop.
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemeToggleCustom" />
|
<FileSource src="/framed/Theme/ThemeToggleCustom" />
|
||||||
|
|
||||||
## Theme select
|
### Theme select
|
||||||
|
|
||||||
Set `render` to `"select"` to display a dropdown menu for selecting from all available themes.
|
Set `render` to `"select"` to render a select dropdown to control the theme.
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemeSelect" />
|
<FileSource src="/framed/Theme/ThemeSelect" />
|
||||||
|
|
||||||
## Theme select (custom)
|
### Theme select (custom)
|
||||||
|
|
||||||
Customize the select dropdown using the `select` prop. You can specify which themes to include, customize labels, and adjust other select properties.
|
Customize the select using the `select` prop.
|
||||||
|
|
||||||
<FileSource src="/framed/Theme/ThemeSelectCustom" />
|
<FileSource src="/framed/Theme/ThemeSelectCustom" />
|
|
@ -1,18 +1,16 @@
|
||||||
|
---
|
||||||
|
source: Tile/Tile.svelte
|
||||||
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { Tile } from "carbon-components-svelte";
|
import { Tile } from "carbon-components-svelte";
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Tile` provides a container for displaying content in a structured, card-like format. It supports light and dark variants and can be used to create consistent, visually distinct content sections.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Create a basic tile container for your content.
|
|
||||||
|
|
||||||
<Tile>Content</Tile>
|
<Tile>Content</Tile>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
|
||||||
|
|
||||||
<Tile light>Content</Tile>
|
<Tile light>Content</Tile>
|
|
@ -7,9 +7,7 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`TimePicker` provides a time input field with optional period (AM/PM) and timezone selectors. It supports various sizes, states, and themes to match your application's design system.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
<TimePicker labelText="Cron job" placeholder="hh:mm">
|
<TimePicker labelText="Cron job" placeholder="hh:mm">
|
||||||
<TimePickerSelect value="pm">
|
<TimePickerSelect value="pm">
|
||||||
|
@ -22,9 +20,7 @@ components: ["TimePicker", "TimePickerSelect", "SelectItem"]
|
||||||
</TimePickerSelect>
|
</TimePickerSelect>
|
||||||
</TimePicker>
|
</TimePicker>
|
||||||
|
|
||||||
## Light variant
|
### Light variant
|
||||||
|
|
||||||
Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
|
||||||
|
|
||||||
<TimePicker light labelText="Cron job" placeholder="hh:mm">
|
<TimePicker light labelText="Cron job" placeholder="hh:mm">
|
||||||
<TimePickerSelect value="pm">
|
<TimePickerSelect value="pm">
|
||||||
|
@ -37,9 +33,7 @@ Use the light variant for light-themed backgrounds by setting `light` to `true`.
|
||||||
</TimePickerSelect>
|
</TimePickerSelect>
|
||||||
</TimePicker>
|
</TimePicker>
|
||||||
|
|
||||||
## Extra-large size
|
### Extra-large size
|
||||||
|
|
||||||
Use the extra-large size for more prominent time pickers by setting `size` to `"xl"`.
|
|
||||||
|
|
||||||
<TimePicker size="xl" labelText="Cron job" placeholder="hh:mm">
|
<TimePicker size="xl" labelText="Cron job" placeholder="hh:mm">
|
||||||
<TimePickerSelect value="pm">
|
<TimePickerSelect value="pm">
|
||||||
|
@ -52,9 +46,7 @@ Use the extra-large size for more prominent time pickers by setting `size` to `"
|
||||||
</TimePickerSelect>
|
</TimePickerSelect>
|
||||||
</TimePicker>
|
</TimePicker>
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size for more compact time pickers by setting `size` to `"sm"`.
|
|
||||||
|
|
||||||
<TimePicker size="sm" labelText="Cron job" placeholder="hh:mm">
|
<TimePicker size="sm" labelText="Cron job" placeholder="hh:mm">
|
||||||
<TimePickerSelect value="pm">
|
<TimePickerSelect value="pm">
|
||||||
|
@ -67,9 +59,7 @@ Use the small size for more compact time pickers by setting `size` to `"sm"`.
|
||||||
</TimePickerSelect>
|
</TimePickerSelect>
|
||||||
</TimePicker>
|
</TimePicker>
|
||||||
|
|
||||||
## Invalid state
|
### Invalid state
|
||||||
|
|
||||||
Indicate an invalid state with an error message by setting `invalid` to `true` and providing `invalidText`.
|
|
||||||
|
|
||||||
<TimePicker invalid invalidText="A valid value is required" labelText="Cron job" placeholder="hh:mm">
|
<TimePicker invalid invalidText="A valid value is required" labelText="Cron job" placeholder="hh:mm">
|
||||||
<TimePickerSelect value="pm">
|
<TimePickerSelect value="pm">
|
||||||
|
@ -82,9 +72,8 @@ Indicate an invalid state with an error message by setting `invalid` to `true` a
|
||||||
</TimePickerSelect>
|
</TimePickerSelect>
|
||||||
</TimePicker>
|
</TimePicker>
|
||||||
|
|
||||||
## Disabled state
|
|
||||||
|
|
||||||
Disable the time picker to prevent user interaction by setting `disabled` to `true`.
|
### Disabled state
|
||||||
|
|
||||||
<TimePicker labelText="Cron job" placeholder="hh:mm" disabled>
|
<TimePicker labelText="Cron job" placeholder="hh:mm" disabled>
|
||||||
<TimePickerSelect value="pm" disabled>
|
<TimePickerSelect value="pm" disabled>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
components: ["ToastNotification"]
|
source: Notification/ToastNotification.svelte
|
||||||
---
|
---
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -7,41 +7,11 @@ components: ["ToastNotification"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`ToastNotification` displays non-modal, time-based messages that appear at the top of the screen and automatically disappear. It supports various notification types, custom content, and accessibility features.
|
### Default (error)
|
||||||
|
|
||||||
See [detailed usage](https://carbondesignsystem.com/components/notification/usage).
|
|
||||||
See also: [InlineNotification](InlineNotification)
|
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic error notification with title, subtitle, and timestamp by default.
|
|
||||||
|
|
||||||
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
||||||
## Autoclose
|
### Slottable title, subtitle, caption
|
||||||
|
|
||||||
Specify the `timeout` prop to automatically close the notification after a specified duration (in milliseconds).
|
|
||||||
|
|
||||||
<FileSource src="/framed/ToastNotification/ToastNotificationTimeout" />
|
|
||||||
|
|
||||||
## Prevent default close behavior
|
|
||||||
|
|
||||||
Prevent the default close behavior using `e.preventDefault()` in the `on:close` event handler.
|
|
||||||
|
|
||||||
<ToastNotification title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" on:close={(e) => {
|
|
||||||
e.preventDefault();
|
|
||||||
// custom close logic (e.g., transitions)
|
|
||||||
}} />
|
|
||||||
|
|
||||||
## Full width
|
|
||||||
|
|
||||||
Set `fullWidth` to `true` for the notification to span the full width of its container.
|
|
||||||
|
|
||||||
<ToastNotification fullWidth title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
|
||||||
|
|
||||||
## Slottable title, subtitle, caption
|
|
||||||
|
|
||||||
Customize the notification content using slots for more flexibility.
|
|
||||||
|
|
||||||
<ToastNotification>
|
<ToastNotification>
|
||||||
<strong slot="title">Error: </strong>
|
<strong slot="title">Error: </strong>
|
||||||
|
@ -49,26 +19,11 @@ Customize the notification content using slots for more flexibility.
|
||||||
<strong slot="caption">{new Date().toLocaleString()}</strong>
|
<strong slot="caption">{new Date().toLocaleString()}</strong>
|
||||||
</ToastNotification>
|
</ToastNotification>
|
||||||
|
|
||||||
## Accessible icon descriptions
|
### Hidden close button
|
||||||
|
|
||||||
Provide custom descriptions for icons to improve accessibility.
|
|
||||||
|
|
||||||
<ToastNotification
|
|
||||||
title="错误"
|
|
||||||
subtitle="发生内部服务器错误"
|
|
||||||
statusIconDescription="错误图标"
|
|
||||||
closeButtonDescription="关闭通知"
|
|
||||||
/>
|
|
||||||
|
|
||||||
## Hidden close button
|
|
||||||
|
|
||||||
Create a persistent notification by hiding the close button.
|
|
||||||
|
|
||||||
<ToastNotification hideCloseButton kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
<ToastNotification hideCloseButton kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
||||||
## Notification variants
|
### Notification variants
|
||||||
|
|
||||||
The component supports different notification types:
|
|
||||||
|
|
||||||
<ToastNotification kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
<ToastNotification kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||||
<ToastNotification kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
<ToastNotification kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||||
|
@ -77,9 +32,7 @@ The component supports different notification types:
|
||||||
<ToastNotification kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
<ToastNotification kind="warning" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
||||||
<ToastNotification kind="warning-alt" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
<ToastNotification kind="warning-alt" title="Scheduled maintenance" subtitle="Maintenance will last 2-4 hours." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
||||||
## Low contrast
|
### Low contrast
|
||||||
|
|
||||||
Use low contrast variants for less prominent notifications.
|
|
||||||
|
|
||||||
<ToastNotification lowContrast kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
<ToastNotification lowContrast kind="error" title="Error" subtitle="An internal server error occurred." caption="{new Date().toLocaleString()}" />
|
||||||
<ToastNotification lowContrast kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
<ToastNotification lowContrast kind="info" title="New updates" subtitle="Restart to get the latest updates." caption="{new Date().toLocaleString()}" />
|
||||||
|
|
|
@ -7,73 +7,47 @@ components: ["Toggle", "ToggleSkeleton"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Toggle` provides a switch-like control that allows users to turn options on or off. It supports custom labels, different sizes, and various states to match your application's needs.
|
### Default (untoggled)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic toggle in its untoggled state by default.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" />
|
<Toggle labelText="Push notifications" />
|
||||||
|
|
||||||
## Toggled
|
### Toggled
|
||||||
|
|
||||||
Set `toggled` to `true` to display the toggle in its on state.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" toggled />
|
<Toggle labelText="Push notifications" toggled />
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
Use two-way binding to control the toggle state programmatically.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Toggle/ToggleReactive" />
|
<FileSource src="/framed/Toggle/ToggleReactive" />
|
||||||
|
|
||||||
## on:toggle event
|
### on:toggle event
|
||||||
|
|
||||||
Listen for toggle state changes using the `on:toggle` event.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" on:toggle={e => console.log(e.detail)} />
|
<Toggle labelText="Push notifications" on:toggle={e => console.log(e.detail)} />
|
||||||
|
|
||||||
## Hidden label text
|
### Custom labels
|
||||||
|
|
||||||
Set `hideLabel` to `true` to visually hide the label while maintaining accessibility.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" hideLabel />
|
|
||||||
|
|
||||||
## Custom labels
|
|
||||||
|
|
||||||
Customize the toggle labels using `labelA` and `labelB` props.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" labelA="No" labelB="Yes" />
|
<Toggle labelText="Push notifications" labelA="No" labelB="Yes" />
|
||||||
|
|
||||||
## Slottable labels
|
### Slottable labels
|
||||||
|
|
||||||
Use slots to customize the toggle labels with additional styling or content.
|
An alternative to the "labelA" and "labelB" props is to use the corresponding named slots.
|
||||||
|
|
||||||
<Toggle labelText="Push notifications">
|
<Toggle labelText="Push notifications">
|
||||||
<span slot="labelA" style="color: red">No</span>
|
<span slot="labelA" style="color: red">No</span>
|
||||||
<span slot="labelB" style="color: green">Yes</span>
|
<span slot="labelB" style="color: green">Yes</span>
|
||||||
</Toggle>
|
</Toggle>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled
|
||||||
|
|
||||||
Set `disabled` to `true` to prevent user interaction.
|
|
||||||
|
|
||||||
<Toggle labelText="Push notifications" disabled />
|
<Toggle labelText="Push notifications" disabled />
|
||||||
|
|
||||||
## Small size
|
### Small size
|
||||||
|
|
||||||
Use the small size variant by setting `size` to `"sm"`.
|
|
||||||
|
|
||||||
<Toggle size="sm" labelText="Push notifications" />
|
<Toggle size="sm" labelText="Push notifications" />
|
||||||
|
|
||||||
## Skeleton
|
### Skeleton
|
||||||
|
|
||||||
Display a loading state using the skeleton component.
|
|
||||||
|
|
||||||
<ToggleSkeleton />
|
<ToggleSkeleton />
|
||||||
|
|
||||||
## Skeleton (small)
|
### Skeleton (small)
|
||||||
|
|
||||||
Use the small size variant for the skeleton component.
|
|
||||||
|
|
||||||
<ToggleSkeleton size="sm" />
|
<ToggleSkeleton size="sm" />
|
|
@ -8,11 +8,9 @@ components: ["Tooltip", "TooltipFooter"]
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`Tooltip` displays contextual information when users hover over or focus on an element. It supports various directions, alignments, and interactive content to provide additional context or guidance.
|
### Default
|
||||||
|
|
||||||
## Default
|
By default, the tooltip is triggered by an information icon.
|
||||||
|
|
||||||
Display a tooltip triggered by the default information icon.
|
|
||||||
|
|
||||||
<Tooltip>
|
<Tooltip>
|
||||||
<p>
|
<p>
|
||||||
|
@ -20,9 +18,7 @@ Display a tooltip triggered by the default information icon.
|
||||||
</p>
|
</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
## With trigger text
|
### With trigger text
|
||||||
|
|
||||||
Use custom trigger text instead of the default icon.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Resource list">
|
<Tooltip triggerText="Resource list">
|
||||||
<p>
|
<p>
|
||||||
|
@ -30,32 +26,24 @@ Use custom trigger text instead of the default icon.
|
||||||
</p>
|
</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
## Reactive example
|
### Reactive example
|
||||||
|
|
||||||
Control the tooltip state programmatically.
|
|
||||||
|
|
||||||
<FileSource src="/framed/Tooltip/TooltipReactive" />
|
<FileSource src="/framed/Tooltip/TooltipReactive" />
|
||||||
|
|
||||||
## Directions
|
### Directions
|
||||||
|
|
||||||
Position the tooltip in different directions using the `direction` prop.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Top" direction="top"><p>Top</p></Tooltip>
|
<Tooltip triggerText="Top" direction="top"><p>Top</p></Tooltip>
|
||||||
<Tooltip triggerText="Right" direction="right"><p>Right</p></Tooltip>
|
<Tooltip triggerText="Right" direction="right"><p>Right</p></Tooltip>
|
||||||
<Tooltip triggerText="Bottom" direction="bottom"><p>Bottom</p></Tooltip>
|
<Tooltip triggerText="Bottom" direction="bottom"><p>Bottom</p></Tooltip>
|
||||||
<Tooltip triggerText="Left" direction="left"><p>Left</p></Tooltip>
|
<Tooltip triggerText="Left" direction="left"><p>Left</p></Tooltip>
|
||||||
|
|
||||||
## Alignment
|
### Alignment
|
||||||
|
|
||||||
Align the tooltip content using the `align` prop.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Start" align="start"><p>Start</p></Tooltip>
|
<Tooltip triggerText="Start" align="start"><p>Start</p></Tooltip>
|
||||||
<Tooltip triggerText="End" align="end"><p>End</p></Tooltip>
|
<Tooltip triggerText="End" align="end"><p>End</p></Tooltip>
|
||||||
<Tooltip triggerText="Center" align="center"><p>Center</p></Tooltip>
|
<Tooltip triggerText="Center" align="center"><p>Center</p></Tooltip>
|
||||||
|
|
||||||
## Interactive
|
### Interactive
|
||||||
|
|
||||||
Add interactive elements like links and buttons using `TooltipFooter`.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Resource list">
|
<Tooltip triggerText="Resource list">
|
||||||
<p>
|
<p>
|
||||||
|
@ -64,12 +52,10 @@ Add interactive elements like links and buttons using `TooltipFooter`.
|
||||||
<TooltipFooter selectorPrimaryFocus="#d">
|
<TooltipFooter selectorPrimaryFocus="#d">
|
||||||
<Link href="/">Learn more</Link>
|
<Link href="/">Learn more</Link>
|
||||||
<Button id="d" size="small">Manage</Button>
|
<Button id="d" size="small">Manage</Button>
|
||||||
</TooltipFooter>
|
</TooltipFooter>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
## Custom icon (component)
|
### Custom icon (component)
|
||||||
|
|
||||||
Use a custom icon component with the `icon` prop.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Resource list" icon={Catalog}>
|
<Tooltip triggerText="Resource list" icon={Catalog}>
|
||||||
<p>
|
<p>
|
||||||
|
@ -77,9 +63,7 @@ Use a custom icon component with the `icon` prop.
|
||||||
</p>
|
</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
## Custom icon (slot)
|
### Custom icon (slot)
|
||||||
|
|
||||||
Customize the icon using the `icon` slot for more flexibility.
|
|
||||||
|
|
||||||
<Tooltip triggerText="Resource list">
|
<Tooltip triggerText="Resource list">
|
||||||
<div slot="icon" style="width: 1rem; height: 1rem; outline: 1px solid red;"></div>
|
<div slot="icon" style="width: 1rem; height: 1rem; outline: 1px solid red;"></div>
|
||||||
|
@ -88,9 +72,7 @@ Customize the icon using the `icon` slot for more flexibility.
|
||||||
</p>
|
</p>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|
||||||
## Hidden icon
|
### Hidden icon
|
||||||
|
|
||||||
Hide the icon while keeping the tooltip functionality using `hideIcon`.
|
|
||||||
|
|
||||||
<Tooltip hideIcon triggerText="Resource list">
|
<Tooltip hideIcon triggerText="Resource list">
|
||||||
<p>
|
<p>
|
||||||
|
|
|
@ -3,27 +3,23 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`TooltipDefinition` provides inline definitions for terms or concepts. It displays a tooltip when users hover over or focus on the defined term, making it ideal for providing additional context without cluttering the interface.
|
### Default
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a basic definition tooltip with the default bottom-center alignment.
|
|
||||||
|
|
||||||
<TooltipDefinition tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
<TooltipDefinition tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
||||||
Armonk
|
Armonk
|
||||||
</TooltipDefinition>
|
</TooltipDefinition>
|
||||||
|
|
||||||
## Custom tooltip direction and alignment
|
### Custom tooltip direction and alignment
|
||||||
|
|
||||||
Customize the tooltip position using the `direction` and `align` props. The default direction is `"bottom"` and alignment is `"center"`.
|
Customize the tooltip menu direction and alignment through the `direction` and `align` props.
|
||||||
|
|
||||||
|
By default, `direction` is `"bottom"` and `align` is `"center"`.
|
||||||
|
|
||||||
<TooltipDefinition direction="top" align="start" tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
<TooltipDefinition direction="top" align="start" tooltipText="IBM Corporate Headquarters is based in Armonk, New York.">
|
||||||
Armonk
|
Armonk
|
||||||
</TooltipDefinition>
|
</TooltipDefinition>
|
||||||
|
|
||||||
## Custom tooltip slot
|
### Custom tooltip slot
|
||||||
|
|
||||||
Use the `tooltip` slot to customize the tooltip content with additional styling or structure.
|
|
||||||
|
|
||||||
<TooltipDefinition>
|
<TooltipDefinition>
|
||||||
Armonk
|
Armonk
|
||||||
|
|
|
@ -5,33 +5,25 @@
|
||||||
import Preview from "../../components/Preview.svelte";
|
import Preview from "../../components/Preview.svelte";
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
`TooltipIcon` displays contextual information when users hover over or focus on an icon. It's ideal for providing additional context about icons or actions in your interface.
|
### Default ("bottom" direction, "center" aligned)
|
||||||
|
|
||||||
## Default
|
|
||||||
|
|
||||||
Display a tooltip with the default bottom-center alignment.
|
|
||||||
|
|
||||||
<TooltipIcon tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
<TooltipIcon tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
||||||
|
|
||||||
## Directions
|
### Directions
|
||||||
|
|
||||||
Position the tooltip in different directions and alignments using the `direction` and `align` props.
|
|
||||||
|
|
||||||
<TooltipIcon tooltipText="Top start" direction="top" align="start" icon={Filter} />
|
<TooltipIcon tooltipText="Top start" direction="top" align="start" icon={Filter} />
|
||||||
<TooltipIcon tooltipText="Right end" direction="right" align="end" icon={Filter} />
|
<TooltipIcon tooltipText="Right end" direction="right" align="end" icon={Filter} />
|
||||||
<TooltipIcon tooltipText="Bottom start" direction="bottom" align="start" icon={Filter} />
|
<TooltipIcon tooltipText="Bottom start" direction="bottom" align="start" icon={Filter} />
|
||||||
<TooltipIcon tooltipText="Left start" direction="left" align="start" icon={Filter} />
|
<TooltipIcon tooltipText="Left start" direction="left" align="start" icon={Filter} />
|
||||||
|
|
||||||
## Custom tooltip text
|
### Custom tooltip text
|
||||||
|
|
||||||
Use the `tooltipText` slot to customize the tooltip content with additional styling.
|
Use the "text" slot to customize the tooltip text.
|
||||||
|
|
||||||
<TooltipIcon icon={Carbon}>
|
<TooltipIcon icon={Carbon}>
|
||||||
<span slot="tooltipText" style="color: red">Carbon is an open source design system by IBM.</span>
|
<span slot="tooltipText" style="color: red">Carbon is an open source design system by IBM.</span>
|
||||||
</TooltipIcon>
|
</TooltipIcon>
|
||||||
|
|
||||||
## Disabled state
|
### Disabled
|
||||||
|
|
||||||
Set `disabled` to `true` to prevent user interaction with the tooltip.
|
|
||||||
|
|
||||||
<TooltipIcon disabled tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
<TooltipIcon disabled tooltipText="Carbon is an open source design system by IBM." icon={Carbon} />
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue