Alongside this entryPopular topics

The Future of CSS: Easy Light-Dark Mode Color Switching with light-dark()

Updated

Read on bram.us

To change a color based on whether Light Mode or Dark Mode used, you’d typically use a prefers-color-scheme Media Query. To make things easier, CSS now comes with a utility function named light-dark(). The function accepts two color values as its arguments. Based on which color scheme you are actively using, it will output the first or the second argument.

Around this post

Replies and reactions from across the web.

Responses from other websites appear here.

    Add your responseLink a post from your own website

    Publish a response on your website and link to this post. Then share its URL below.

    Webmention connects the posts. Responses appear after verification.