How to get dark mode in Amplify UI work?

0

I am following an example from the official document to setup dark mode. But it only apply dark mode to the ToggleButtonGroup, and does not apply to entire page. Does anyone has used dark mode in Amplify UI?

hai
질문됨 2년 전366회 조회
2개 답변
0

Select dark mode from the Account drop down on top right> Settings > Visual mode> select dark mode.

답변함 일 년 전
0

Here is the process you can go through.

1.Set Up AWS Amplify Project

2.Design Dark Mode CSS: Create a new CSS file or modify your existing CSS to define the styles for the dark mode theme. You'll need to identify the relevant CSS classes or selectors used in your application and provide alternative styles for dark mode. For example, you might adjust background colors, text colors, and other visual elements.

/* Sample dark mode CSS */
body.dark-mode {
  background-color: #1a1a1a;
  color: #ffffff;
}
  1. Enable Dark Mode Toggle: Add a UI element, such as a button or a toggle switch, to allow users to switch between light mode and dark mode. This UI element will trigger the theme change when clicked.
    <!-- Sample dark mode toggle button -->
    <button id="darkModeToggle">Toggle Dark Mode</button>
  2. JavaScript to Switch Themes: Write JavaScript code to handle the theme toggle. This code will detect the user's preference and apply the dark mode CSS when the user chooses the dark mode option.
   // Sample JavaScript to toggle dark mode
   const darkModeToggle = document.getElementById('darkModeToggle');
   const body = document.body;

   darkModeToggle.addEventListener('click', () => {
     body.classList.toggle('dark-mode');
   });
AWS
답변함 9달 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠