Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(manifest): Improve theme_color member page #35643

Merged
merged 8 commits into from
Sep 3, 2024
Merged
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
101 changes: 92 additions & 9 deletions files/en-us/web/manifest/theme_color/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,110 @@ browser-compat: html.manifest.theme_color

{{QuickLinksWithSubpages("/en-US/docs/Web/Manifest")}}

<table class="properties">
<tbody>
<tr>
<th scope="row">Type</th>
<td><code>String</code></td>
</tr>
</tbody>
</table>
The `theme_color` member specifies the default color for your web application's user interface.
This color may be applied to various browser UI elements, such as the toolbar, address bar, and status bar.
It can be particularly noticeable in contexts like the task switcher or when the app is added to the home screen.

The `theme_color` member is a string that defines the default theme color for the application. This sometimes affects how the OS displays the site (e.g., on Android's task switcher, the theme color surrounds the site).
This color application can provide a more native app-like experience for your web app, especially when it's loaded in [standalone](/en-US/docs/Web/Manifest/display#standalone) mode.

## Syntax

```json
"theme_color": "colorValue"
dipikabh marked this conversation as resolved.
Show resolved Hide resolved
```

### Values

- `colorValue`
dipikabh marked this conversation as resolved.
Show resolved Hide resolved

- : A string that specifies a [valid color value](/en-US/docs/Web/CSS/color_value).
dipikabh marked this conversation as resolved.
Show resolved Hide resolved

> [!NOTE]
> Browsers may ignore the alpha component of the color based on the context.
> In most environments, `theme_color` cannot be transparent.
> It's recommended to use fully opaque colors (alpha value of 1 or 100%) to ensure consistent behavior across different platforms and browsers.

## Description

While optional, specifying a `theme_color` allows you to extend your app's visual identity beyond its content areas.
Choose a `theme_color` that aligns with your app's brand guidelines, as this can enhance user recognition and recall, particularly when your app is viewed alongside other applications or system interfaces.

In browsers that support `theme_color`, the value specified in the manifest file serves as the default theme color for your web app across all pages where the manifest is applied.
You can override this default in the following ways:

- Using the [`theme-color`](/en-US/docs/Web/HTML/Element/meta/name/theme-color) value of the `name` attribute in the HTML `<meta>` element: You can specify a theme color for a web page that's different from the manifest `theme_color` specified for your app. This enables you to set different theme colors for individual pages within your app.

```html
<meta name="theme-color" content="#9370DB" />
```

- Combining the `<meta name="theme-color">` element with media queries: You can specify the theme color to be used based on user's color scheme preference.

```html
<meta
name="theme-color"
content="#F4E6D8"
media="(prefers-color-scheme: light)" />
<meta
name="theme-color"
content="#5D4037"
media="(prefers-color-scheme: dark)" />
```

These override methods provide you the flexibility to adapt your app's appearance for specific pages or user preferences, improving the overall user experience.

Browsers may also adjust the applied theme color based on user preferences.
If a user has set a preference for light or dark mode, browsers may override the manifest `theme_color` value to support any [`prefers-color-scheme`](/en-US/docs/Web/CSS/@media/prefers-color-scheme) media query defined in your app's CSS.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps

Suggested change
If a user has set a preference for light or dark mode, browsers may override the manifest `theme_color` value to support any [`prefers-color-scheme`](/en-US/docs/Web/CSS/@media/prefers-color-scheme) media query defined in your app's CSS.
If a user has set a preference for light or dark mode, browsers may override the manifest `theme_color` value to better match any [`prefers-color-scheme`](/en-US/docs/Web/CSS/@media/prefers-color-scheme) media query defined in your app's CSS.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, I think it might be better to stick to what spec has, which is "support"

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Support is definitely "sub optimal", but perhaps "comply with" would be better. Not worth arguing about.


```css
body {
background: #f8f9fa;
color: #212529;
}

@media (prefers-color-scheme: dark) {
body {
background: #212529;
color: #f8f9fa;
}
}
```

## Examples

### Using a named color

```json
"theme_color": "red"
```

### Using an RGB value

```json
"theme_color": "rgb(66, 133, 244)"
```

### Using a hexadecimal value

```json
{
"name": "MyWebApp",
dipikabh marked this conversation as resolved.
Show resolved Hide resolved
"display": "standalone",
"background_color": "#ffffff",
"theme_color": "#ff4500"
}
```

## Specifications

{{Specifications}}

## Browser compatibility

{{Compat}}

## See also

- [`display`](/en-US/docs/Web/Manifest/display) manifest member
- [`background_color`](/en-US/docs/Web/Manifest/background_color) manifest member
- [`scope`](/en-US/docs/Web/Manifest/scope) manifest member