:class and :style in Vue

Vue interview exercise on Templates & reactivity, difficulty 1 of 3. Solve it in the editor beside a worked example; the tests run the moment you do.

Write Badge with props `label` (required), `status` ("ok" | "warn" | "error", default "ok"), `big` (boolean) and `color` (optional CSS colour): a <span> with the static class "badge", the class "badge-<status>", the class "big" while big is true, and an inline `color` style only when color is given. It shows the label.

Each exercise pairs a worked example with a twin problem to solve in a real editor; the tests run the moment you do. Progress is saved in your browser, and in your account if you sign in.

More Templates & reactivity in Vue

All Vue exercises · Other languages and frameworks