> Documentation index: https://www.gooddata.ai/docs/gooddata-ui/llms.txt lists every page of these docs as Markdown.

# useTheme()

- Package: [@gooddata/sdk-ui-theme-provider](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-ui-theme-provider/index.md)
- Kind: function
- Source: https://github.com/gooddata/gooddata-ui-sdk/blob/rel/11.64/libs/sdk-ui-theme-provider/src/ThemeProvider/Context.tsx
- Guides: [useTheme](https://www.gooddata.ai/docs/gooddata-ui/latest/integrations/hooks/use-theme/index.md)

Hook for reaching the theme from context.

**Signature:**

```typescript
useTheme: (theme?: ITheme) => ITheme | undefined
```

## Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| theme | [ITheme](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.itheme/index.md) | _(Optional)_ theme to use instead of context value. If undefined, the context value is used. |

**Returns:**

[ITheme](https://www.gooddata.ai/docs/gooddata-ui/latest/api-reference/sdk-model/sdk-model.itheme/index.md) &#124; undefined

## Remarks

You can optionally set a theme override that will be returned if defined. This makes the usage more ergonomic (see the following example).

## Example

```tsx
// instead of
const fromContext = useTheme();
const effectiveTheme = fromArguments ?? fromContext.
// you can write
const theme = useTheme(fromArguments);
```
