Description
The SwiftUI is a great UI development framework for the iOS app. After I wrote some to-be-released app with the SwiftUI framework, I realized that I need a solution to write more clear, simple, view-style-decoupled code with lots of custom style design.
So here is SwiftUI-CSS.
The missing CSS-like module for SwiftUI alternatives and similar libraries
Based on the "UI" category.
Alternatively, view The missing CSS-like module for SwiftUI alternatives based on common mentions on social networks and blogs.
-
Lottie
An iOS library to natively render After Effects vector animations -
DZNEmptyDataSet
A drop-in UITableView/UICollectionView superclass category for showing empty datasets whenever the view has no content to display -
IQKeyboardManager
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more. -
MBProgressHUD
MBProgressHUD + Customizations -
iCarousel
A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS -
IGListKit
A data-driven UICollectionView framework for building fast and flexible lists. -
MJRefresh
An easy way to use pull-to-refresh. -
AsyncDisplayKit
Smooth asynchronous user interfaces for iOS apps. -
SVProgressHUD
A clean and lightweight progress HUD for your iOS and tvOS app. -
Hero
Elegant transition library for iOS & tvOS -
folding-cell
:octocat: 📃 FoldingCell is an expanding content cell with animation made by @Ramotion -
TTTAttributedLabel
A drop-in replacement for UILabel that supports attributes, data detectors, links, and more -
SkeletonView
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting -
Eureka
Elegant iOS form builder in Swift -
FSCalendar
A fully customizable iOS calendar library, compatible with Objective-C and Swift -
animated-tab-bar
:octocat: RAMAnimatedTabBarController is a Swift UI module library for adding animation to iOS tabbar items and icons. iOS library made by @Ramotion -
NVActivityIndicatorView
A collection of awesome loading animations -
Material
A UI/UX framework for creating beautiful applications. -
LTMorphingLabel
[EXPERIMENTAL] Graceful morphing effects for UILabel written in Swift. -
XLPagerTabStrip
Android PagerTabStrip for iOS. -
MGSwipeTableCell
An easy to use UITableViewCell subclass that allows to display swippable buttons with a variety of transitions. -
Texture
Smooth asynchronous user interfaces for iOS apps. -
RESideMenu
iOS 7/8 style side menu with parallax effect. -
SWTableViewCell
An easy-to-use UITableViewCell subclass that implements a swippable content view which exposes utility buttons (similar to iOS 7 Mail Application) -
FlatUIKit
A collection of awesome flat UI components for iOS. -
ViewAnimator
ViewAnimator brings your UI to life with just one line -
JTAppleCalendar
The Unofficial Apple iOS Swift Calendar View. Swift calendar Library. iOS calendar Control. 100% Customizable -
SwiftMessages
A very flexible message bar for iOS written in Swift. -
XLForm
XLForm is the most flexible and powerful iOS library to create dynamic table-view forms. Fully compatible with Swift & Obj-C. -
JVFloatLabeledTextField
UITextField subclass with floating labels - inspired by Matt D. Smith's design: http://dribbble.com/shots/1254439--GIF-Mobile-Form-Interaction?list=users -
TPKeyboardAvoiding
A drop-in universal solution for moving text fields out of the way of the keyboard in iOS -
FSPagerView
FSPagerView is an elegant Screen Slide Library. It is extremely helpful for making Banner View、Product Show、Welcome/Guide Pages、Screen/ViewController Sliders. -
SVPullToRefresh
Give pull-to-refresh & infinite scrolling to any UIScrollView with 1 line of code. -
SwipeCellKit
Swipeable UITableViewCell/UICollectionViewCell based on the stock Mail.app, implemented in Swift. -
ComponentKit
A React-inspired view framework for iOS. -
AMScrollingNavbar
Scrollable UINavigationBar that follows the scrolling of a UIScrollView -
Macaw
Powerful and easy-to-use vector graphics Swift library with SVG support -
Koloda
KolodaView is a class designed to simplify the implementation of Tinder like cards on iOS. -
SWRevealViewController
A UIViewController subclass for presenting side view controllers inspired on the FaceBook and Wunderlist apps, done right ! -
expanding-collection
:octocat: ExpandingCollection is an animated material design UI card peek/pop controller. iOS library made by @Ramotion -
PageMenu
A paging menu controller built from other view controllers placed inside a scroll view (like Spotify, Windows Phone, Instagram) -
SCLAlertView-Swift
Beautiful animated Alert View. Written in Swift -
TextFieldEffects
Custom UITextFields effects inspired by Codrops, built using Swift -
SwiftEntryKit
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps. -
ViewDeck
An implementation of the sliding menu found in various iOS apps. -
Alerts & Pickers
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date... -
Material Components
[In maintenance mode] Modular and customizable Material Design UI components for iOS -
TSMessages
💌 Easy to use and customizable messages/notifications for iOS à la Tweetbot -
SideMenu
Simple side/slide menu control for iOS, no code necessary! Lots of customization. Add it to your project in 5 minutes or less.
Appwrite - The Open Source Firebase alternative introduces iOS support
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of The missing CSS-like module for SwiftUI or a related project?
Popular Comparisons
-
The missing CSS-like module for SwiftUIvsIQKeyboardManager
-
The missing CSS-like module for SwiftUIvsNVActivityIndicatorView
-
The missing CSS-like module for SwiftUIvsXLPagerTabStrip
-
The missing CSS-like module for SwiftUIvsAMScrollingNavbar
-
The missing CSS-like module for SwiftUIvsMBProgressHUD
README
The missing CSS-like module for SwiftUI
Check out the example project using SwiftUI-CSS; Also, Swift Package availble which url is
https://github.com/hite/SwiftUI-CSS
Supported macOS(.v10_14), .iOS(.v13) The SwiftUI is a great UI development framework for the iOS app. After I wrote some to-be-released app with SwiftUI framework, I realized that I need a solution to write more clear, simple, view-style-decoupled code with lots of custom style design.
So here is SwiftUI-CSS. With SwiftUI-CSS, you can:
1. write View-style-decoupled codes
View-style-decoupled makes your source code more clear to read, easy to refactor like html with CSS support.
Without SwifUI-CSS:
The codes to define View Structure blend into style-defined codes.
Image("image-swift")
.resizable()
.scaledToFit()
.frame(width:100, height:100)
.cornerRadius(10)
.padding(EdgeInsets(top: 10, leading: 0, bottom: 15, trailing: 0))
Text("Swift")
.font(.headline)
.foregroundColor(Color(red: 0x33/0xff, green: 0x33/0xff, blue: 0x33/0xff))
.padding(.bottom, 10)
Text("Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, Linux, and z/OS. ")
.font(.footnote)
.padding(.horizontal, 10)
.foregroundColor(NormalDescColor)
.lineSpacing(2)
.frame(minHeight: 100, maxHeight: .infinity)
With SwifUI-CSS:
- We divide the previous into two parts. The first part is view structures with class name:
Image("image-swift")
.resizable()
.scaledToFit()
.addClassName(languageLogo_clsName)
Text("Swift")
.addClassName(languageTitle_clsName)
Text("Swift is a general-purpose, multi-paradigm, compiled programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, Linux, and z/OS. ")
.addClassName(languageDesc_clsName)
- The another is style definition: ``` swift let languageLogo_clsName = CSSStyle([ .width(100), .height(100), .cornerRadius(10), .paddingTLBT(10, 0, 15,0) ])
let languageTitle_clsName = CSSStyle([ .font(.headline), .foregroundColor(Color(red: 0x33/0xff, green: 0x33/0xff, blue: 0x33/0xff)), .paddingEdges([.bottom], 10) ])
let languageDesc_clsName = CSSStyle([ .font(.footnote), .paddingHorizontal(10), .foregroundColor(NormalDescColor), .lineSpacing(2), .flexHeight(min: 50, max: .infinity) ])
## 2. use module system for reuse or create a custom design system.
*module system* help to reuse some common style design across the whole app which can save you to write same codes everywhere or avoid to make some mistakes.
### Without SwifUI-CSS:
If you change the style of Text("28 October 2014"), you must change the style of Text("Objective-C,[7] Rust, Haskell, Ruby, Python, C#, CLU,[8] D[9]") too.
```swift
// in html5.swift
HStack() {
Text("Initial release:")
.font(Font.system(size: 14))
Text("28 October 2014")
.font(Font.system(size: 12))
.foregroundColor(NormalDescColor)
}
// in swift.swift
HStack(alignment: .top) {
Text("Influenced by:")
.font(Font.system(size: 14))
Text("Objective-C,[7] Rust, Haskell, Ruby, Python, C#, CLU,[8] D[9]")
.font(Font.system(size: 12))
.foregroundColor(NormalDescColor)
}
With SwiftUI-CSS
You can change the definition of wikiDesc_clsName once for all.
let wikiDesc_clsName = CSSStyle([
.font(Font.system(size: 12)),
.foregroundColor(NormalDescColor)
])
// in html5.swift
HStack() {
Text("Initial release:")
.font(Font.system(size: 14))
Text("28 October 2014")
.addClassName(wikiDesc_clsName)
}
// in swift.swift
HStack(alignment: .top) {
Text("Influenced by:")
.font(Font.system(size: 14))
Text("Objective-C,[7] Rust, Haskell, Ruby, Python, C#, CLU,[8] D[9]")
.addClassName(wikiDesc_clsName)
}
the other benefits of using SwiftUI-CSS
- more easy to change a lot of styles when state change. ``` swift // without swiftui-css if festival == 'Christmas' { Text("Welcome everyone!") .font(.largeTitle) .foreground(.white) .background(.red) } else { Text("Welcome everyone!") .font(.title) .foreground(.darkGray) .background(.white) }
// with Text("Welcome everyone!") .addClassName(fesitval == 'Christmas' ? chrismas_clsName: normal_clsName)
2. Maybe a reachable way to convert html+css codes to swiftui source
3. write less code, clear to tell parameters meanings. For example.
> `.frame(minHeight: 50, maxheight: .infinity` to `.flexHeight(min: 50, max: .infinity)`
> `.padding(EdgeInset(top:10, leading: 15, bottom:0, trailing: 20)` to `.paddingTLBT(10,15,0,20)`
4. You can combile some different style into one.
```swift
let fontStyle = CSSStyle([.font(.caption)])
let colorStyle = CSSStyle([.backgroundColor(.red)])
let finalStyle = fontStyle + colorStyle
print("finalStyle = \(finalStyle)")
- use responsive class to make view larger on larger screen
swift // In iOS, if the sketch file designed for screen 375x667, the responsive fator should be compared to UIScreen.main.bounds.size.width. let responsive = Responsive(UIScreen.main.bounds.size.width / 375) let wikiDesc_clsName = CSSStyle([ .font(Font.system(size: responsive.r(12))), .foregroundColor(NormalDescColor) .paddingEdges([.bottom], responsive.r(10)) ])