Dark Theme on Pixels Admin
How can I get Pixels-Admin to respect the dark theme? To begin with, this auth page isn't dark (as specified with the following on the ConfigProvider:
<ConfigProvider
theme={{
algorithm: theme.darkAlgorithm
}}
>
And here is the code for the auth page:
import * as React from "react";
import { Link } from "react-router-dom";
import { AuthPage as AntdAuthPage, AuthProps } from "@refinedev/antd";
import { Image } from "antd";
import { StackBanner } from "../../components/banners";
const authWrapperProps = {
style: {
backgroundImage: "url('/bg.png')",
backgroundRepeat: "repeat-x",
},
};
// const contentProps = {
// style: {
// backgroundColor: "#fff",
// border: "1px solid #f5f5f5",
// borderRadius: "16px",
// boxShadow: "4px 8px 16px rgba(42, 42, 66, 0.25)",
// width: "384px",
// padding: "16px",
// },
// };
const renderAuthContent = (content: React.ReactNode) => {
return (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Link to="/" style={{ marginBottom: "32px" }}>
<Image
height="160"
src="/pixels-logo.svg"
alt="pixels-logo"
preview={false}
/>
</Link>
{content}
<StackBanner />
</div>
);
};
export const AuthPage: React.FC<AuthProps> = ({ type, formProps, ...rest }) => {
return (
<AntdAuthPage
type={type}
wrapperProps={authWrapperProps}
renderContent={renderAuthContent}
formProps={formProps}
{...rest}
/>
);
};
5 Replies
Hi @obelisk291. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To ensure that the Pixels Admin respects the dark theme, you need to make sure that the
ConfigProvider
from Ant Design is correctly set up to use the dark theme algorithm. Additionally, you should verify that the AuthPage
component and other components are correctly inheriting the theme settings.
Here is a step-by-step guide to achieve this:
1. Set up the ConfigProvider
with the dark theme algorithm:
Ensure that your ConfigProvider
is correctly configured to use the dark theme algorithm. This should be done at the root of your application.
2. Ensure the AuthPage
component respects the theme:
The AuthPage
component should be set up to inherit the theme from the ConfigProvider
. The provided code for the AuthPage
component should work correctly if the ConfigProvider
is set up properly.
```jsx
import * as React from "react";
import { Link } from "react-router-dom";
import { AuthPage as AntdAuthPage, AuthProps } from "@refinedev/antd";
import { Image } from "antd";
import { StackBanner } from "../../components/banners";
const authWrapperProps = {
style: {
backgroundImage: "url('/bg.png')",
backgroundRepeat: "repeat-x",
},
};
const renderAuthContent = (content: React.ReactNode) => {
return (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Link to="/" style={{ marginBottom: "32px" }}>
<
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1257731147509661728> kapa.ai is still learning and improving, please let us know how it did by reacting below
stormy-goldOP•7mo ago
@kapa.ai You didn't finish your output
Let me check the knowledge base for you. One moment! :books:
----------------------
To ensure that the Pixels Admin respects the dark theme, you need to make sure that the
ConfigProvider
from Ant Design is correctly set up to use the dark theme algorithm. Additionally, you should verify that the AuthPage
component and other components are correctly inheriting the theme settings.
Here is a step-by-step guide to achieve this:
1. Set up the ConfigProvider
with the dark theme algorithm:
Ensure that your ConfigProvider
is correctly configured to use the dark theme algorithm. This should be done at the root of your application.
2. Ensure the AuthPage
component respects the theme:
The AuthPage
component should be set up to inherit the theme from the ConfigProvider
. The provided code for the AuthPage
component should work correctly if the ConfigProvider
is set up properly.
```jsx
import * as React from "react";
import { Link } from "react-router-dom";
import { AuthPage as AntdAuthPage, AuthProps } from "@refinedev/antd";
import { Image } from "antd";
import { StackBanner } from "../../components/banners";
const authWrapperProps = {
style: {
backgroundImage: "url('/bg.png')",
backgroundRepeat: "repeat-x",
},
};
const renderAuthContent = (content: React.ReactNode) => {
return (
<div
style={{
display: "flex",
flexDirection: "column",
justifyContent: "center",
alignItems: "center",
}}
>
<Link to="/" style={{ marginBottom: "
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------<@1257731147509661728> kapa.ai is still learning and improving, please let us know how it did by reacting below