Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@smui/common

hperrin59.5kApache-2.08.0.0-beta.3TypeScript support: included

Svelte Material UI - Common

svelte, svelte3, material-ui, material-design, material, svelte-components, sveltejs

readme

Svelte Material UI

A library of Svelte Material UI components, based on Material Design Components - Web.

Demos, Code Samples, and Guides

https://sveltematerialui.com

Features

Here are some unique features that help SMUI stand out:

  • Full TypeScript support, including HTML attributes.
  • You can add arbitrary attributes to all of the components and many of the elements within them.
  • You can add actions to the components with use={[Action1, [Action2, action2Props], Action3]}.
  • You can add props to lower components and elements with "$" props, like input$maxlength="15".
  • SMUI supports RTL languages.

Installation

To get started, check out the installation docs or the SvelteKit docs.

Need Help?

If you need help installing or using SMUI, join the Discord server.

Svelte 5

SMUI v8 requires Svelte 5. This is the documentation for v8, which is still in development (and is currently in a prerelease state).

If you are using Svelte 4, you can use SMUI v7, which is the current stable version. Check out the v7 branch for the current docs.

Migration

Upgrading from an old version? Be sure to read the migration doc.

Upgrading from v7? You need Svelte 5. Event listeners no longer to use the CustomEvent type. Check out the upgrade instructions.

Upgrading from v6? You need Svelte 4. No more elemental components; you can now use the "tag" prop to change the element. No more "ComponentDev" types; components can now be used as their type. Check out the upgrade instructions.

Upgrading from v5? If you're still using the advanced styling method, it's really time to switch to the easy styling method. '/styled' endpoints are no longer provided. Check out the upgrade instructions.

Upgrading from v4? SMUI v5 requires the TypeScript preprocessor. SMUI v6 does not though, so if you upgrade straight to v6, don't worry. Check out the upgrade instructions.

Upgrading from v3? SMUI's styling method has been simplified. Check out the upgrade instructions.

Upgrading from v2? There are lots of changes listed in the upgrade instructions.

Old Docs

You can find older versions of the docs on their respective branch:

Icons

You can include icons in a number of ways, but the easiest is the Material Icon Font. This will give you the standard set of Material Icons, available with the CSS class "material-icons".

<link
  href="https://fonts.googleapis.com/icon?family=Material+Icons"
  rel="stylesheet"
/>

However, there are two downsides. First is that all icons are downloaded, no matter which ones you use, so the size over the wire will almost certainly be more than necessary. Second is that it only includes the Material Icons from Google.

Another option is the Material Design Icons library. See the "Using SVGs" demo on the Icon Button demo page for instructions to use icons from the @mdi/js package (or any other SVG icons).

You can even use them in data URLs. To get a data URL for the icon:

  1. Find your icon and click "Copy SVG" button (it looks like </>).
  2. Base64 encode the document.
  3. Format the URL like this data:image/svg+xml;base64,encodedcontent, replacing "encodedcontent" with the Base64 results.
  4. Now you have an image URL you can use in an "img" tag src attribute or anywhere else you put an image URL (like background-image: url();).

Components

Click a component/package below to go to the documentation. (Note that this documentation is a work in progress. The demo code should be your main source of truth for how something works.)

† This is Sass based, and therefore doesn't require Svelte components. I've included a demo showing how you can use it.

‡ This is not an MDC-Web component (upstream library). It is an addition that SMUI provides.

  • Labels and icons are named exports in the components that use them, or you can use the 'Label' and 'Icon' exports from '@smui/common'. (Except for chips labels and icons, textfield icons, and select icons, because they are special snowflakes.)

License

Copyright 2019-2024 Hunter Perrin

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

changelog

Change Log

All notable changes to this project will be documented in this file. See Conventional Commits for commit guidelines.

8.0.0-beta.3 (2024-12-22)

Bug Fixes

  • sigh, svelte 5 doesn't support what classAdderBuilder needs, so it had to be refactored (a4df13c)

8.0.0-beta.2 (2024-12-13)

Bug Fixes

  • use svelte event on instead of addEventListener (11b68e7)

8.0.0-beta.1 (2024-12-11)

Bug Fixes

  • finish some migration steps, update readme (95fbdc2)
  • migrate away from svelte:component (8cc6c77)
  • remove bindable rune from things that don't need it (2b77cf8)
  • shorten runes options and snippet renders (d1368a6)
  • type issues (0424a48)

Features

  • migrate components in common to runes (0b14a99)
  • migrate components in list to runes (6ece353)
  • migrate components in menu to runes (42a84e8)

8.0.0-beta.0 (2024-11-19)

Bug Fixes

  • event names (642c2a3)
  • update classadder to work with new svelte component functions (54a4266)

Features

  • add chip-input component (4e82fd8)

8.0.0-alpha.0 (2024-05-13)

Bug Fixes

  • custom component types (fa5b473)
  • explicitly opt out of runes mode in all components (96b69f9)

Features

  • events for svelte 5, mount events to contexts, event modifiers, remove custom event typing (52d60b8)
  • remove deprecated MDC event names (df78b17)
  • remove forwardEventsBuilder, since it's no longer used (63a2e95)

7.0.0 (2024-05-04)

Note: Version bump only for package @smui/common

7.0.0-beta.18 (2024-03-17)

Note: Version bump only for package @smui/common

7.0.0-beta.17 (2024-03-13)

Note: Version bump only for package @smui/common

7.0.0-beta.16 (2023-12-27)

Bug Fixes

  • cast component type to something ts likes (017039f)
  • typescript and accessibility issues with menus and select inputs (5b4794f)

7.0.0-beta.15 (2023-09-04)

Bug Fixes

  • add declaration files to work around rollup typescript resolving modules to the src directory (b09a46b), closes #556

7.0.0-beta.14 (2023-06-30)

Bug Fixes

  • move omit generic down line to fix union type that is too complex to represent type error (b26b1d4)

7.0.0-beta.13 (2023-06-29)

Bug Fixes

  • rework tag prop to allow svg, simplify prop types to fix ts error (d1610c8)

7.0.0-beta.12 (2023-06-29)

Note: Version bump only for package @smui/common

7.0.0-beta.11 (2023-06-29)

Note: Version bump only for package @smui/common

7.0.0-beta.10 (2023-06-28)

Bug Fixes

  • import ambient types from index files for ts event support (d62e12c)
  • reference ambient types instead of importing them (2d1193c)
  • remove reliance on svelte internals from forward events builder (dea2cc9)
  • suppress typescript issues with importing svelte internals (985183c)

Features

  • migration to Svelte 4 in components (51d2411)
  • use new generics definitions for better typing of components with tag prop (4476f3a)

7.0.0-beta.9 (2023-06-20)

Note: Version bump only for package @smui/common

7.0.0-beta.8 (2023-04-29)

Note: Version bump only for package @smui/common

7.0.0-beta.7 (2023-04-29)

Note: Version bump only for package @smui/common

7.0.0-beta.6 (2023-04-29)

Note: Version bump only for package @smui/common

7.0.0-beta.5 (2023-04-28)

Note: Version bump only for package @smui/common

7.0.0-beta.4 (2023-04-24)

Note: Version bump only for package @smui/common

7.0.0-beta.3 (2023-04-06)

Note: Version bump only for package @smui/common

7.0.0-beta.2 (2023-04-06)

Bug Fixes

  • exported type of ClassAdder component (7f35915)
  • never confuse an exported function type with an html attr type (d00860a), closes #575

7.0.0-beta.1 (2023-04-04)

Bug Fixes

Features

  • redo autocomplete resetTextWhenSelected option, use event cancelation instead (78950d4)

7.0.0-beta.0 (2022-10-12)

Bug Fixes

  • default element in common icon (98b1536)
  • turns out, svelte still doesn't report exported module members in typescript (72702aa)
  • use separate svg component and fix all type errors (9accd0b)

Features

  • migrate to common element component instead of elemental components (8aaf611)
  • new common element component with dynamic element support (bfa69d2)
  • new typing method gets rid of separate type files, keeps html prop autocomplete (bf7b2a4)
  • redo type system to bring types into their svelte files (61b9395)
  • trying to get components with generic types working (9952576)
  • update to mdc-web 14, implement new features and fixes (cca1827)

6.1.4 (2022-09-27)

Bug Fixes

  • update svelte-strip for module script lang fix (2dc89a9)

6.1.0 (2022-08-20)

Note: Version bump only for package @smui/common

6.0.0 (2022-07-23)

Bug Fixes

  • update sveltekit and fix package.json (9dfb3d0), closes #425
  • upgrade packages and fix issues with new versions (67f45cc)

6.0.0-beta.16 (2022-04-11)

Bug Fixes

6.0.0-beta.15 (2022-03-02)

Note: Version bump only for package @smui/common

6.0.0-beta.14 (2022-02-13)

Bug Fixes

  • rename type attributes to lang (88a45ff)
  • update to latest packages, sveltekit and fix issues (ca21255)

Features

  • add label elemental component (533b085)
  • update SvelteKit and move types to separate imports (5fb1216)

6.0.0-beta.13 (2022-01-05)

Bug Fixes

  • import everything from material correctly. replace announce function with own implementation (7ac0383)

6.0.0-beta.12 (2022-01-05)

Bug Fixes

  • correct entries in package.json files, noExternal config no longer needed (95c56b5), closes #375

6.0.0-beta.11 (2021-12-29)

Note: Version bump only for package @smui/common

6.0.0-beta.10 (2021-12-28)

Note: Version bump only for package @smui/common

6.0.0-beta.9 (2021-12-15)

Note: Version bump only for package @smui/common

6.0.0-beta.8 (2021-12-14)

Note: Version bump only for package @smui/common

6.0.0-beta.7 (2021-12-14)

Note: Version bump only for package @smui/common

6.0.0-beta.6 (2021-12-11)

Bug Fixes

  • remove unused args on unsubscribe (a7f2aca)

6.0.0-beta.5 (2021-12-10)

Note: Version bump only for package @smui/common

6.0.0-beta.4 (2021-11-25)

Note: Version bump only for package @smui/common

6.0.0-beta.3 (2021-11-24)

Bug Fixes

  • include svelte tsconfig from common module (2cfc838)

6.0.0-beta.2 (2021-11-17)

Bug Fixes

  • common doesn't have a default export (a29127f)

6.0.0-beta.1 (2021-11-17)

Bug Fixes

  • lock to last good ts minor version, add index files for repl (d77c735)

6.0.0-beta.0 (2021-11-17)

Bug Fixes

  • get sass compiling for all packages (6405961)
  • get sass compiling in dev env for site with smui-theme (08fd30f)
  • rm deprecation warn by updating to material 12 + breaking changes (e3e95e1)
  • update other packages, move svelte to peerDependencies (2c1b137)

Features

  • new package directory structure, include stripped svelte files so no preprocess needed (382e78d)
  • remove styled endpoints and update readme and installation docs (c8755d4)
  • rename MDC events to SMUI events (55effc6)
  • upgrade mdc-web packages to v13 (9f0457f)

BREAKING CHANGES

  • No more styled endpoints, so the advanced styling method now requires that you import the Sass yourself.

5.0.1 (2021-11-16)

Bug Fixes

  • classadder not loaded from explicit path (46c5a3c)

5.0.0 (2021-11-10)

Features

  • let segmented button selection be controlled manually (835ef80)

5.0.0-beta.8 (2021-11-02)

Note: Version bump only for package @smui/common

5.0.0-beta.7 (2021-09-28)

Bug Fixes

  • cannot access internals before initialization (d297517), closes #329

5.0.0-beta.6 (2021-09-27)

Bug Fixes

  • internals causing issues being outside of class adder component (1c29076), closes #329
  • lock sass to the last working minor release (62d4895), closes #334

5.0.0-beta.5 (2021-09-18)

Bug Fixes

  • remove smui.d file and SMUIComponent declaration class (ef30919)

5.0.0-beta.4 (2021-09-17)

Note: Version bump only for package @smui/common

5.0.0-beta.3 (2021-09-17)

Bug Fixes

  • include extensions in import paths (3c06e33)

Features

BREAKING CHANGES

  • Bare endpoints in packages have been removed. You don't need them.

5.0.0-beta.1 (2021-09-14)

Bug Fixes

  • correctly provide html attributes (048a11d)
  • some type issues and simpler ambient declarations (44e2cea)

5.0.0-beta.0 (2021-09-14)

Bug Fixes

  • listeners for manually forwarded events bound with modifiers were called twice (3096ffc)
  • some more type errors (f4b8568)
  • type errors after making site package strict (7cdcad9)

Features

  • add prop types for HTML props for components (f5c6e53)
  • implement js builds of all ts files (085b829)
  • migrate banner to typescript (dae0f3c)
  • migrate card to typescript (c1a9ef2)
  • migrate chips to typescript (075f48a)
  • migrate common and button to typescript (cf9c6af)
  • migrate fab and icon button to typescript (5e81e89)
  • migrate list, checkbox, and radio to typescript (6b475a5)
  • migrate menu surface and menu to typescript (b479315)
  • migrate slider to typescript (42c8c00)
  • migrate textfield to typescript (0010211)

BREAKING CHANGES

  • Renamed SMUI events from like SMUI:component:event to like SMUIComponent:event.

4.2.0 (2021-05-05)

Bug Fixes

  • events with modifiers called once for every event listener on event (4234efa)

Features

  • allow customizing Label component, add Em and Strong elemental components (5dd42e2)

4.1.0 (2021-04-28)

Bug Fixes

  • warnings about unexpected slot in Img and Hr (98a555f)

Features

  • change event modifier syntax to allow use on all events (1fe4f82)

Reverts

4.0.0 (2021-04-24)

Features

  • remove style importing from index files, no more /bare (2ab900a)

3.1.0 (2021-04-22)

Features

  • update to MDC 11, new fullscreen dialogs (ee962bc)

Reverts

3.0.2 (2021-04-21)

Features

  • new easy styling method (9c58fc9)

3.0.1 (2021-04-21)

Features

  • implement fixes and workarounds for Vite and SvelteKit (9ed43aa)

Reverts

3.0.0 (2021-04-19)

Note: Version bump only for package @smui/common

3.0.0-beta.12 (2021-04-18)

Note: Version bump only for package @smui/common

3.0.0-beta.11 (2021-04-18)

Features

  • new Data Table Column Sort feature (c831855)
  • new Data Table Pagination component (267f31d)

3.0.0-beta.10 (2021-04-17)

Features

  • new Segmented Button component (4b1dc50)

3.0.0-beta.9 (2021-04-16)

Note: Version bump only for package @smui/common

3.0.0-beta.8 (2021-04-15)

Features

  • forward all events, and only forward when bound, and allow modifiers (50a0db3)

3.0.0-beta.7 (2021-04-15)

Note: Version bump only for package @smui/common

3.0.0-beta.6 (2021-04-14)

Note: Version bump only for package @smui/common

3.0.0-beta.5 (2021-04-14)

Bug Fixes

  • classAdderBuilder polluting ClassAdder internals (b484114)

3.0.0-beta.4 (2021-04-12)

Features

3.0.0-beta.3 (2021-04-12)

Note: Version bump only for package @smui/common

3.0.0-beta.2 (2021-04-11)

Note: Version bump only for package @smui/common

3.0.0-beta.1 (2021-04-11)

Bug Fixes

  • svgs in icon buttons were focusable (f9d2678)

3.0.0-beta.0 (2021-04-11)

Bug Fixes

  • fixed event bubbling (8b40fa0)
  • more components fixes (fbdf204)
  • selection dialog and stacked buttons styling (d0987ca)

Features

  • add getElement method to all components (f293cf3)
  • started updating List for MDC v10 (8bf2727)
  • updated Chips for MDC v10 (5ca1c05)
  • updated IconButton for MDC v10 (1a6fc5a)
  • updated Image List for MDC v10 (015db52)
  • updated site for SMUI 3 components (f24c25f)
  • updated Snackbars and Kitchen for MDC v10 (78974e5)
  • updated TopAppBar for MDC v10 (6cf291d)
  • upgrade upstream MDC components to v10 (d47c59a)

BREAKING CHANGES

  • Upgrading to v10 of upstream components. Their APIs will change. View the component READMEs.

2.0.0-beta.1 (2021-03-27)

Note: Version bump only for package @smui/common

2.0.0-beta.0 (2021-01-01)

Note: Version bump only for package @smui/common

2.0.0-alpha.0 (2020-12-31)

Bug Fixes

  • fix buttons, ripples, and list item for new mdc (9b902b5)

Features

  • update chips to work with MDC 4 (2c28796)

BREAKING CHANGES

  • Chips has several breaking changes listed in the migration docs.

1.0.0 (2020-08-04)

Note: Version bump only for package @smui/common

1.0.0-beta.21 (2020-04-19)

Bug Fixes

  • undefined current_component in browsers not supporting import #60 (708abd6)

1.0.0-beta.20 (2020-01-31)

Features

  • add component option to Button to allow other elements/components (95d4d49)

1.0.0-beta.19 (2019-12-13)

Bug Fixes

  • prevent new Svelte versions from mangling MDC classes (8a94e95), closes #52

1.0.0-beta.15 (2019-09-13)

Bug Fixes

  • fixed ClassAdder components to allow SSR (de0daa1), closes #29

1.0.0-beta.14 (2019-09-07)

Bug Fixes

  • fixed the packages' sass commands (97d64ea)