{"id":5564,"date":"2024-04-26T10:08:46","date_gmt":"2024-04-26T02:08:46","guid":{"rendered":"https:\/\/www.aisharenet.com\/?p=5564"},"modified":"2025-07-14T12:03:12","modified_gmt":"2025-07-14T04:03:12","slug":"shadcnui","status":"publish","type":"post","link":"https:\/\/www.kdjingpai.com\/ja\/shadcnui\/","title":{"rendered":"shadcn\/ui\uff1a\u7ec4\u4ef6\u5e93\u6784\u5efa\u5e73\u53f0"},"content":{"rendered":"<p>shadcn\/ui \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u7ec4\u4ef6\u5e93\u6784\u5efa\u5e73\u53f0\uff0c\u63d0\u4f9b\u4e86\u7f8e\u89c2\u4e14\u53ef\u5b9a\u5236\u7684UI\u7ec4\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u7ec4\u4ef6\u590d\u5236\u7c98\u8d34\u5230\u81ea\u5df1\u7684\u5e94\u7528\u4e2d\u3002\u8be5\u5e73\u53f0\u652f\u6301\u591a\u79cd\u524d\u7aef\u6846\u67b6\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u5b89\u88c5\u548c\u4f7f\u7528\u6307\u5357\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u4e0a\u624b\u5e76\u6784\u5efa\u81ea\u5df1\u7684\u7ec4\u4ef6\u5e93\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-5565\" title=\"shadcn\/ui\uff1a\u7ec4\u4ef6\u5e93\u6784\u5efa\u5e73\u53f0-1\" src=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b.png\" alt=\"shadcn\/ui\uff1a\u7ec4\u4ef6\u5e93\u6784\u5efa\u5e73\u53f0-1\" width=\"862\" height=\"384\" srcset=\"https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b.png 1686w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b-300x134.png 300w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b-1024x457.png 1024w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b-768x343.png 768w, https:\/\/www.kdjingpai.com\/wp-content\/uploads\/2024\/08\/ceecf5dbf897b6b-1536x685.png 1536w\" sizes=\"auto, (max-width: 862px) 100vw, 862px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>\u529f\u80fd\u5217\u8868<\/h2>\n<ul>\n<li>\u63d0\u4f9b\u591a\u79cd\u7f8e\u89c2\u7684UI\u7ec4\u4ef6<\/li>\n<li>\u652f\u6301\u591a\u79cd\u524d\u7aef\u6846\u67b6\uff08\u5982Next.js, Vite, Remix\u7b49\uff09<\/li>\n<li>\u63d0\u4f9bTypeScript\u548cJavaScript\u7248\u672c\u7684\u7ec4\u4ef6<\/li>\n<li>\u8be6\u7ec6\u7684\u5b89\u88c5\u548c\u4f7f\u7528\u6307\u5357<\/li>\n<li>\u5f00\u6e90\u4e14\u514d\u8d39\u4f7f\u7528<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<h2>\u4f7f\u7528\u5e2e\u52a9<\/h2>\n<h3>\u5b89\u88c5\u6d41\u7a0b<\/h3>\n<ol>\n<li><strong>\u9009\u62e9\u6846\u67b6<\/strong>\uff1a\u6839\u636e\u9879\u76ee\u9700\u6c42\u9009\u62e9\u652f\u6301\u7684\u6846\u67b6\uff0c\u5982Next.js, Vite, Remix, Gatsby, Astro, Laravel\u7b49\u3002<\/li>\n<li><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong>\uff1a\u4f7f\u7528npm\u6216yarn\u5b89\u88c5\u6240\u9700\u7684\u4f9d\u8d56\u5305\u3002\n<pre><code class=\"language-bash\">npm install @shadcn\/ui\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u914d\u7f6e\u9879\u76ee<\/strong>\uff1a\u6839\u636e\u6240\u9009\u6846\u67b6\u7684\u8981\u6c42\uff0c\u914d\u7f6e\u9879\u76ee\u6587\u4ef6\u3002\u4f8b\u5982\uff0c\u914d\u7f6eTypeScript\u6216JavaScript\u7248\u672c\uff0c\u8bbe\u7f6eTailwind CSS\u7b49\u3002\n<pre><code class=\"language-json\"><span class=\"hljs-punctuation\">{<\/span>\r\n  <span class=\"hljs-attr\">\"style\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"default\"<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n  <span class=\"hljs-attr\">\"tailwind\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span>\r\n    <span class=\"hljs-attr\">\"config\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"tailwind.config.js\"<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n    <span class=\"hljs-attr\">\"css\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"src\/app\/globals.css\"<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n    <span class=\"hljs-attr\">\"baseColor\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"zinc\"<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n    <span class=\"hljs-attr\">\"cssVariables\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">true<\/span><\/span>\r\n  <span class=\"hljs-punctuation\">}<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n  <span class=\"hljs-attr\">\"rsc\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">false<\/span><\/span><span class=\"hljs-punctuation\">,<\/span>\r\n  <span class=\"hljs-attr\">\"tsx\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-literal\"><span class=\"hljs-keyword\">false<\/span><\/span><span class=\"hljs-punctuation\">,<\/span>\r\n  <span class=\"hljs-attr\">\"aliases\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-punctuation\">{<\/span>\r\n    <span class=\"hljs-attr\">\"utils\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"~\/lib\/utils\"<\/span><span class=\"hljs-punctuation\">,<\/span>\r\n    <span class=\"hljs-attr\">\"components\"<\/span><span class=\"hljs-punctuation\">:<\/span> <span class=\"hljs-string\">\"~\/components\"<\/span>\r\n  <span class=\"hljs-punctuation\">}<\/span>\r\n<span class=\"hljs-punctuation\">}<\/span>\r\n<\/code><\/pre>\n<\/li>\n<li><strong>\u5bfc\u5165\u7ec4\u4ef6<\/strong>\uff1a\u5728\u9879\u76ee\u4e2d\u5bfc\u5165\u5e76\u4f7f\u7528\u6240\u9700\u7684\u7ec4\u4ef6\u3002\n<pre><code class=\"language-javascript\"><span class=\"hljs-keyword\">import<\/span> { <span class=\"hljs-title class_\">Button<\/span> } <span class=\"hljs-keyword\">from<\/span> <span class=\"hljs-string\">'@shadcn\/ui'<\/span>;\r\n<\/code><\/pre>\n<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3>\u4f7f\u7528\u6307\u5357<\/h3>\n<ol>\n<li><strong>\u6d4f\u89c8\u7ec4\u4ef6\u5e93<\/strong>\uff1a\u8bbf\u95eeshadcn\/ui\u5b98\u7f51\uff0c\u6d4f\u89c8\u53ef\u7528\u7684\u7ec4\u4ef6\uff0c\u9009\u62e9\u9002\u5408\u9879\u76ee\u9700\u6c42\u7684\u7ec4\u4ef6\u3002<\/li>\n<li><strong>\u590d\u5236\u7c98\u8d34\u7ec4\u4ef6\u4ee3\u7801<\/strong>\uff1a\u5c06\u5b98\u7f51\u63d0\u4f9b\u7684\u7ec4\u4ef6\u4ee3\u7801\u590d\u5236\u7c98\u8d34\u5230\u9879\u76ee\u4e2d\uff0c\u8fdb\u884c\u5fc5\u8981\u7684\u81ea\u5b9a\u4e49\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u7ec4\u4ef6<\/strong>\uff1a\u6839\u636e\u9879\u76ee\u9700\u6c42\uff0c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u6837\u5f0f\u548c\u529f\u80fd\u3002shadcn\/ui\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u914d\u7f6e\u9009\u9879\uff0c\u652f\u6301\u901a\u8fc7Tailwind CSS\u8fdb\u884c\u6837\u5f0f\u5b9a\u5236\u3002<\/li>\n<li><strong>\u6d4b\u8bd5\u548c\u8c03\u8bd5<\/strong>\uff1a\u5728\u9879\u76ee\u4e2d\u6d4b\u8bd5\u7ec4\u4ef6\u7684\u529f\u80fd\u548c\u6837\u5f0f\uff0c\u786e\u4fdd\u5176\u7b26\u5408\u9884\u671f\u3002<\/li>\n<li><strong>\u53d1\u5e03\u9879\u76ee<\/strong>\uff1a\u5b8c\u6210\u7ec4\u4ef6\u96c6\u6210\u540e\uff0c\u8fdb\u884c\u9879\u76ee\u7684\u6784\u5efa\u548c\u53d1\u5e03\u3002<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<h3>\u8be6\u7ec6\u64cd\u4f5c\u6d41\u7a0b<\/h3>\n<ul>\n<li><strong>\u5b89\u88c5\u4f9d\u8d56<\/strong>\uff1a\u786e\u4fdd\u9879\u76ee\u4e2d\u5df2\u5b89\u88c5\u5fc5\u8981\u7684\u4f9d\u8d56\u5305\uff0c\u5982React, Tailwind CSS\u7b49\u3002<\/li>\n<li><strong>\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a\u6839\u636e\u9879\u76ee\u9700\u6c42\uff0c\u914d\u7f6etsconfig.json\u6216jsconfig.json\u6587\u4ef6\uff0c\u8bbe\u7f6e\u8def\u5f84\u522b\u540d\u7b49\u3002<\/li>\n<li><strong>\u5bfc\u5165\u7ec4\u4ef6<\/strong>\uff1a\u5728\u9700\u8981\u4f7f\u7528\u7ec4\u4ef6\u7684\u6587\u4ef6\u4e2d\uff0c\u5bfc\u5165\u5e76\u4f7f\u7528shadcn\/ui\u63d0\u4f9b\u7684\u7ec4\u4ef6\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u6837\u5f0f<\/strong>\uff1a\u4f7f\u7528Tailwind CSS\u6216\u5176\u4ed6\u6837\u5f0f\u5de5\u5177\uff0c\u81ea\u5b9a\u4e49\u7ec4\u4ef6\u7684\u5916\u89c2\u3002<\/li>\n<li><strong>\u8c03\u8bd5\u548c\u4f18\u5316<\/strong>\uff1a\u5728\u5f00\u53d1\u8fc7\u7a0b\u4e2d\uff0c\u8fdb\u884c\u7ec4\u4ef6\u7684\u8c03\u8bd5\u548c\u4f18\u5316\uff0c\u786e\u4fdd\u5176\u6027\u80fd\u548c\u517c\u5bb9\u6027\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>shadcn\/ui \u662f\u4e00\u4e2a\u5f00\u6e90\u7684\u7ec4\u4ef6\u5e93\u6784\u5efa\u5e73\u53f0\uff0c\u63d0\u4f9b\u4e86\u7f8e\u89c2\u4e14\u53ef\u5b9a\u5236\u7684UI\u7ec4\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u8fd9\u4e9b\u7ec4\u4ef6\u590d\u5236\u7c98\u8d34\u5230\u81ea\u5df1\u7684\u5e94\u7528\u4e2d\u3002\u8be5\u5e73\u53f0\u652f\u6301\u591a\u79cd\u524d\u7aef\u6846\u67b6\uff0c\u5e76\u63d0\u4f9b\u8be6\u7ec6\u7684\u5b89\u88c5\u548c\u4f7f\u7528\u6307\u5357\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u5feb\u901f\u4e0a\u624b\u5e76\u6784\u5efa\u81ea\u5df1\u7684\u7ec4\u4ef6\u5e93\u3002 &nbsp; &nbsp; &#8230;<\/p>\n","protected":false},"author":1,"featured_media":32356,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[208],"class_list":["post-5564","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tool","tag-aikaifangfuwu"],"_links":{"self":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/5564","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/comments?post=5564"}],"version-history":[{"count":0,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/posts\/5564\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media\/32356"}],"wp:attachment":[{"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/media?parent=5564"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/categories?post=5564"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.kdjingpai.com\/ja\/wp-json\/wp\/v2\/tags?post=5564"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}