You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+61-2Lines changed: 61 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,15 +34,74 @@ func main() {
34
34
35
35
- See [tailwind-merge](https://github.com/dcastil/tailwind-merge/blob/v2.2.1/docs/limitations.md)
36
36
37
+
## Advanced Examples
38
+
39
+
You might also want to check out the advanced example at `/cmd/examples/advanced`
40
+
41
+
### Provide Your Own or Extend Default Config
42
+
43
+
```go
44
+
import (
45
+
// Note the import path here is different from the default path. This is so you have access to all the custom functions, structs, etc that are used to build the twmerge config
TwMerger = twmerge.CreateTwMerge(config, nil) // config, cache (if nil default will be used)
57
+
58
+
59
+
// example usage
60
+
m:=TwMerger("px-4 px-10", "p-20")
61
+
fmt.Println(m) // output: "p-20"
62
+
}
63
+
```
64
+
65
+
### Provide your own Cache
66
+
67
+
The default cache is a LRU Cache and should be acceptable for most use cases. However, you might want to provide your own cache or modify the default creation parameters. Your cache must implement the interface defined at `/pkg/cache/cache.go`
68
+
69
+
```go
70
+
typeICacheinterface {
71
+
Get(string) string
72
+
Set(string, string) // key, value
73
+
}
74
+
```
75
+
76
+
Here is an example of manually creating the default cache with a custom max capacity
0 commit comments