The Startup
Published in

The Startup

Changing HTML Class in Svelte Components with the Class Directive

Photo by NeONBRAND on Unsplash

Svelte is an up and coming front end framework for developing front end web apps.

It’s simple to use and lets us create results fast.

In this article, we’ll look at how to change class names dynamically with the Svelte class directive.

Class Directive




Get smarter at building your thing. Follow to join The Startup’s +8 million monthly readers & +756K followers.

Recommended from Medium

CSS Hover and Transform Examples and Repo

Redux-Actions through Example: Part 3

JavaScript Unit Test Best Practices — Basics

How to track your React App using Google analytics

GA with react

The Many Ways to Construct JavaScript Objects

Add Transition Effects to a Svelte App

Node.js Tips — Request URLs, Parsing Request Bodies, Upload

JavaScript Events Handlers — oncontextmenu and oncuechange

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
John Au-Yeung

John Au-Yeung

Web developer. Subscribe to my email list now at Email me at

More from Medium

Everything you need to know about arrays in JavaScript

To Code or Not To Code?

4 JavaScript Promise Methods — All, AllSettled, Any, and Race